Revision 5083fc47
b/snf-astakos-app/astakos/im/presentation.py | ||
---|---|---|
84 | 84 |
'verbose_name': 'System Disk', |
85 | 85 |
'group': 'compute' |
86 | 86 |
}, |
87 |
'cyclades.ram': { |
|
87 |
'cyclades.total_ram': {
|
|
88 | 88 |
'help_text': 'RAM used by VMs ', |
89 | 89 |
'help_text_input_each': ('This is the total amount of RAM that ' |
90 | 90 |
'will be granted to each user of this ' |
91 | 91 |
'Project (on all VMs) '), |
92 | 92 |
'is_abbreviation': True, |
93 |
'report_desc': 'RAM', |
|
93 |
'report_desc': 'Total RAM',
|
|
94 | 94 |
'placeholder': 'eg. 4GB', |
95 |
'verbose_name': 'ram', |
|
95 |
'verbose_name': 'Total ram',
|
|
96 | 96 |
'group': 'compute' |
97 | 97 |
|
98 | 98 |
}, |
99 |
'cyclades.active_ram': {
|
|
99 |
'cyclades.ram': { |
|
100 | 100 |
'help_text': 'RAM used by active VMs ', |
101 | 101 |
'help_text_input_each': ('This is the total amount of RAM that ' |
102 | 102 |
'will be granted to each user of this ' |
103 | 103 |
'Project (on all active VMs) '), |
104 | 104 |
'is_abbreviation': False, |
105 |
'report_desc': 'Active RAM',
|
|
105 |
'report_desc': 'RAM', |
|
106 | 106 |
'placeholder': 'eg. 4GB', |
107 |
'verbose_name': 'Active RAM',
|
|
107 |
'verbose_name': 'RAM', |
|
108 | 108 |
'group': 'compute' |
109 | 109 |
|
110 | 110 |
}, |
111 |
'cyclades.cpu': { |
|
111 |
'cyclades.total_cpu': {
|
|
112 | 112 |
'help_text': 'CPUs used by VMs ', |
113 | 113 |
'help_text_input_each': ('This is the total number of CPUs that ' |
114 | 114 |
'will be granted to each user of this ' |
115 | 115 |
'Project (on all VMs) '), |
116 | 116 |
'is_abbreviation': True, |
117 |
'report_desc': 'CPUs', |
|
117 |
'report_desc': 'Total CPUs',
|
|
118 | 118 |
'placeholder': 'eg. 1', |
119 |
'verbose_name': 'cpu', |
|
119 |
'verbose_name': 'Total cpu',
|
|
120 | 120 |
'group': 'compute' |
121 | 121 |
|
122 | 122 |
}, |
123 |
'cyclades.active_cpu': {
|
|
123 |
'cyclades.cpu': { |
|
124 | 124 |
'help_text': 'CPUs used by active VMs ', |
125 | 125 |
'help_text_input_each': ('This is the total number of CPUs that ' |
126 | 126 |
'will be granted to each user of this ' |
127 | 127 |
'Project (on all active VMs) '), |
128 | 128 |
'is_abbreviation': False, |
129 |
'report_desc': 'Active CPUs',
|
|
129 |
'report_desc': 'CPUs', |
|
130 | 130 |
'placeholder': 'eg. 1', |
131 |
'verbose_name': 'Active CPU',
|
|
131 |
'verbose_name': 'CPU', |
|
132 | 132 |
'group': 'compute' |
133 | 133 |
|
134 | 134 |
}, |
... | ... | |
186 | 186 |
'groups_order': ['storage', 'compute', 'network', 'accounts'], |
187 | 187 |
'resources_order': ['pithos.diskspace', |
188 | 188 |
'cyclades.disk', |
189 |
'cyclades.total_cpu', |
|
189 | 190 |
'cyclades.cpu', |
190 |
'cyclades.active_cpu',
|
|
191 |
'cyclades.total_ram',
|
|
191 | 192 |
'cyclades.ram', |
192 |
'cyclades.active_ram', |
|
193 | 193 |
'cyclades.vm', |
194 | 194 |
'cyclades.network.private', |
195 | 195 |
'cyclades.floating_ip', |
b/snf-astakos-app/astakos/im/static/im/css/modules.css | ||
---|---|---|
512 | 512 |
.stats .info p { color:#999; margin:0; } |
513 | 513 |
.stats .info h3 { font-size:1.231em; color:#222222 } |
514 | 514 |
.stats .vm .img-wrap { background-image:url(../images/vm-stats.png) } |
515 |
.stats .ram .img-wrap { background-image:url(../images/ram-stats.png) }
|
|
516 |
.stats .active_ram .img-wrap { background-image:url(../images/ram-stats.png) }
|
|
517 |
.stats .cpu .img-wrap { background-image:url(../images/cpu-stats.png) }
|
|
518 |
.stats .active_cpu .img-wrap { background-image:url(../images/cpu-stats.png) }
|
|
515 |
.stats .total_ram .img-wrap { background-image:url(../images/ram-stats.png) }
|
|
516 |
.stats .ram .img-wrap { background-image:url(../images/ram-stats.png) }
|
|
517 |
.stats .total_cpu .img-wrap { background-image:url(../images/cpu-stats.png) }
|
|
518 |
.stats .cpu .img-wrap { background-image:url(../images/cpu-stats.png) }
|
|
519 | 519 |
.stats .network .img-wrap { background-image:url(../images/network-stats.png) } |
520 | 520 |
.stats .disksize .img-wrap { background-image:url(../images/disk-stats.png) } |
521 | 521 |
.stats .disk .img-wrap { background-image:url(../images/disk-stats.png) } |
b/snf-astakos-app/astakos/scripts/snf_service_export.py | ||
---|---|---|
77 | 77 |
"service_type": "compute", |
78 | 78 |
"service_origin": "cyclades_compute", |
79 | 79 |
}, |
80 |
'cpu': { |
|
81 |
"name": "cyclades.cpu", |
|
80 |
'total_cpu': {
|
|
81 |
"name": "cyclades.total_cpu",
|
|
82 | 82 |
"desc": "Number of virtual machine processors", |
83 | 83 |
"service_type": "compute", |
84 | 84 |
"service_origin": "cyclades_compute", |
85 | 85 |
}, |
86 |
'active_cpu': {
|
|
87 |
"name": "cyclades.active_cpu",
|
|
86 |
'cpu': { |
|
87 |
"name": "cyclades.cpu", |
|
88 | 88 |
"desc": "Number of virtual machine processors of running" |
89 | 89 |
" servers", |
90 | 90 |
"service_type": "compute", |
91 | 91 |
"service_origin": "cyclades_compute", |
92 | 92 |
}, |
93 |
'ram': { |
|
94 |
"name": "cyclades.ram", |
|
93 |
'total_ram': {
|
|
94 |
"name": "cyclades.total_ram",
|
|
95 | 95 |
"desc": "Virtual machine memory size", |
96 | 96 |
"unit": "bytes", |
97 | 97 |
"service_type": "compute", |
98 | 98 |
"service_origin": "cyclades_compute", |
99 | 99 |
}, |
100 |
'active_ram': {
|
|
101 |
"name": "cyclades.active_ram",
|
|
100 |
'ram': { |
|
101 |
"name": "cyclades.ram", |
|
102 | 102 |
"desc": "Virtual machine memory size of running servers", |
103 | 103 |
"unit": "bytes", |
104 | 104 |
"service_type": "compute", |
b/snf-cyclades-app/synnefo/api/services.py | ||
---|---|---|
51 | 51 |
"service_type": "compute", |
52 | 52 |
"service_origin": "cyclades_compute", |
53 | 53 |
}, |
54 |
'cpu': { |
|
55 |
"name": "cyclades.cpu", |
|
54 |
'total_cpu': {
|
|
55 |
"name": "cyclades.total_cpu",
|
|
56 | 56 |
"desc": "Number of virtual machine processors", |
57 | 57 |
"service_type": "compute", |
58 | 58 |
"service_origin": "cyclades_compute", |
59 | 59 |
}, |
60 |
'active_cpu': {
|
|
61 |
"name": "cyclades.active_cpu",
|
|
60 |
'cpu': { |
|
61 |
"name": "cyclades.cpu", |
|
62 | 62 |
"desc": "Number of virtual machine processors of running" |
63 | 63 |
" servers", |
64 | 64 |
"service_type": "compute", |
65 | 65 |
"service_origin": "cyclades_compute", |
66 | 66 |
}, |
67 |
'ram': { |
|
68 |
"name": "cyclades.ram", |
|
67 |
'total_ram': {
|
|
68 |
"name": "cyclades.total_ram",
|
|
69 | 69 |
"desc": "Virtual machine memory size", |
70 | 70 |
"unit": "bytes", |
71 | 71 |
"service_type": "compute", |
72 | 72 |
"service_origin": "cyclades_compute", |
73 | 73 |
}, |
74 |
'active_ram': {
|
|
75 |
"name": "cyclades.active_ram",
|
|
74 |
'ram': { |
|
75 |
"name": "cyclades.ram", |
|
76 | 76 |
"desc": "Virtual machine memory size of running servers", |
77 | 77 |
"unit": "bytes", |
78 | 78 |
"service_type": "compute", |
b/snf-cyclades-app/synnefo/quotas/__init__.py | ||
---|---|---|
46 | 46 |
DEFAULT_SOURCE = 'system' |
47 | 47 |
RESOURCES = [ |
48 | 48 |
"cyclades.vm", |
49 |
"cyclades.total_cpu", |
|
49 | 50 |
"cyclades.cpu", |
50 |
"cyclades.active_cpu", |
|
51 | 51 |
"cyclades.disk", |
52 |
"cyclades.total_ram", |
|
52 | 53 |
"cyclades.ram", |
53 |
"cyclades.active_ram", |
|
54 | 54 |
"cyclades.network.private", |
55 | 55 |
"cyclades.floating_ip", |
56 | 56 |
] |
... | ... | |
280 | 280 |
if isinstance(resource, VirtualMachine): |
281 | 281 |
flavor = resource.flavor |
282 | 282 |
resources = {"cyclades.vm": 1, |
283 |
"cyclades.cpu": flavor.cpu, |
|
283 |
"cyclades.total_cpu": flavor.cpu,
|
|
284 | 284 |
"cyclades.disk": 1073741824 * flavor.disk, |
285 |
"cyclades.ram": 1048576 * flavor.ram} |
|
286 |
online_resources = {"cyclades.active_cpu": flavor.cpu,
|
|
287 |
"cyclades.active_ram": 1048576 * flavor.ram}
|
|
285 |
"cyclades.total_ram": 1048576 * flavor.ram}
|
|
286 |
online_resources = {"cyclades.cpu": flavor.cpu, |
|
287 |
"cyclades.ram": 1048576 * flavor.ram} |
|
288 | 288 |
if action == "BUILD": |
289 | 289 |
resources.update(online_resources) |
290 | 290 |
return resources |
... | ... | |
311 | 311 |
beparams = action_fields.get("beparams") |
312 | 312 |
cpu = beparams.get("vcpus", flavor.cpu) |
313 | 313 |
ram = beparams.get("maxmem", flavor.ram) |
314 |
return {"cyclades.cpu": cpu - flavor.cpu, |
|
315 |
"cyclades.ram": 1048576 * (ram - flavor.ram)} |
|
314 |
return {"cyclades.total_cpu": cpu - flavor.cpu,
|
|
315 |
"cyclades.total_ram": 1048576 * (ram - flavor.ram)}
|
|
316 | 316 |
else: |
317 | 317 |
#["CONNECT", "DISCONNECT", "SET_FIREWALL_PROFILE"]: |
318 | 318 |
return None |
b/snf-cyclades-app/synnefo/quotas/tests.py | ||
---|---|---|
56 | 56 |
mfactory.VirtualMachineFactory(flavor=flavor, userid="user1", |
57 | 57 |
operstate="BUILD") |
58 | 58 |
user_holdings = {"user1": {"cyclades.vm": 1, |
59 |
"cyclades.total_cpu": 24, |
|
59 | 60 |
"cyclades.cpu": 24, |
60 |
"cyclades.active_cpu": 24, |
|
61 | 61 |
"cyclades.disk": 21474836480, |
62 |
"cyclades.ram": 8589934592, |
|
63 |
"cyclades.active_ram": 8589934592}}
|
|
62 |
"cyclades.total_ram": 8589934592,
|
|
63 |
"cyclades.ram": 8589934592}} |
|
64 | 64 |
holdings = util.get_db_holdings(user="user1") |
65 | 65 |
self.assertEqual(holdings, user_holdings) |
66 | 66 |
holdings = util.get_db_holdings() |
... | ... | |
70 | 70 |
mfactory.VirtualMachineFactory(flavor=flavor, userid="user2", |
71 | 71 |
operstate="STARTED") |
72 | 72 |
user_holdings = {"user2": {"cyclades.vm": 1, |
73 |
"cyclades.total_cpu": 24, |
|
73 | 74 |
"cyclades.cpu": 24, |
74 |
"cyclades.active_cpu": 24, |
|
75 | 75 |
"cyclades.disk": 21474836480, |
76 |
"cyclades.ram": 8589934592, |
|
77 |
"cyclades.active_ram": 8589934592}}
|
|
76 |
"cyclades.total_ram": 8589934592,
|
|
77 |
"cyclades.ram": 8589934592}} |
|
78 | 78 |
holdings = util.get_db_holdings(user="user2") |
79 | 79 |
self.assertEqual(holdings, user_holdings) |
80 | 80 |
mfactory.VirtualMachineFactory(flavor=flavor, userid="user3", |
81 | 81 |
operstate="STOPPED") |
82 | 82 |
user_holdings = {"user3": {"cyclades.vm": 1, |
83 |
"cyclades.cpu": 24, |
|
83 |
"cyclades.total_cpu": 24,
|
|
84 | 84 |
"cyclades.disk": 21474836480, |
85 |
"cyclades.ram": 8589934592}} |
|
85 |
"cyclades.total_ram": 8589934592}}
|
|
86 | 86 |
holdings = util.get_db_holdings(user="user3") |
87 | 87 |
self.assertEqual(holdings, user_holdings) |
88 | 88 |
|
... | ... | |
138 | 138 |
#commission = quotas.get_commission_info(vm, "BUILD") |
139 | 139 |
#self.assertEqual({"cyclades.vm": 1, |
140 | 140 |
# "cyclades.cpu": 2, |
141 |
# "cyclades.active_cpu": 2, |
|
141 |
# "cyclades.cpu": 2, |
|
142 |
# "cyclades.ram": 1048576 * 1024, |
|
142 | 143 |
# "cyclades.ram": 1048576 * 1024, |
143 |
# "cyclades.active_ram": 1048576 * 1024, |
|
144 | 144 |
# "cyclades.disk": 1073741824 * 20}, commission) |
145 | 145 |
vm.operstate = "STARTED" |
146 | 146 |
vm.save() |
147 | 147 |
commission = quotas.get_commission_info(vm, "STOP") |
148 |
self.assertEqual({"cyclades.active_cpu": -2,
|
|
149 |
"cyclades.active_ram": 1048576 * -1024}, commission)
|
|
148 |
self.assertEqual({"cyclades.cpu": -2, |
|
149 |
"cyclades.ram": 1048576 * -1024}, commission) |
|
150 | 150 |
# Check None quotas if vm is already stopped |
151 | 151 |
vm.operstate = "STOPPED" |
152 | 152 |
vm.save() |
153 | 153 |
commission = quotas.get_commission_info(vm, "STOP") |
154 | 154 |
self.assertEqual(None, commission) |
155 | 155 |
commission = quotas.get_commission_info(vm, "START") |
156 |
self.assertEqual({"cyclades.active_cpu": 2,
|
|
157 |
"cyclades.active_ram": 1048576 * 1024}, commission)
|
|
156 |
self.assertEqual({"cyclades.cpu": 2, |
|
157 |
"cyclades.ram": 1048576 * 1024}, commission) |
|
158 | 158 |
vm.operstate = "STARTED" |
159 | 159 |
vm.save() |
160 | 160 |
commission = quotas.get_commission_info(vm, "DESTROY") |
161 | 161 |
self.assertEqual({"cyclades.vm": -1, |
162 |
"cyclades.total_cpu": -2, |
|
162 | 163 |
"cyclades.cpu": -2, |
163 |
"cyclades.active_cpu": -2,
|
|
164 |
"cyclades.total_ram": 1048576 * -1024,
|
|
164 | 165 |
"cyclades.ram": 1048576 * -1024, |
165 |
"cyclades.active_ram": 1048576 * -1024, |
|
166 | 166 |
"cyclades.disk": 1073741824 * -20}, commission) |
167 | 167 |
vm.operstate = "STOPPED" |
168 | 168 |
vm.save() |
169 | 169 |
commission = quotas.get_commission_info(vm, "DESTROY") |
170 | 170 |
self.assertEqual({"cyclades.vm": -1, |
171 |
"cyclades.cpu": -2, |
|
172 |
"cyclades.ram": 1048576 * -1024, |
|
171 |
"cyclades.total_cpu": -2,
|
|
172 |
"cyclades.total_ram": 1048576 * -1024,
|
|
173 | 173 |
"cyclades.disk": 1073741824 * -20}, commission) |
174 | 174 |
commission = quotas.get_commission_info(vm, "RESIZE") |
175 | 175 |
self.assertEqual(None, commission) |
176 | 176 |
commission = quotas.get_commission_info(vm, "RESIZE", |
177 | 177 |
{"beparams": {"vcpus": 4, |
178 | 178 |
"maxmem": 2048}}) |
179 |
self.assertEqual({"cyclades.cpu": 2, |
|
180 |
"cyclades.ram": 1048576 * 1024}, commission) |
|
179 |
self.assertEqual({"cyclades.total_cpu": 2,
|
|
180 |
"cyclades.total_ram": 1048576 * 1024}, commission)
|
|
181 | 181 |
vm.operstate = "STOPPED" |
182 | 182 |
vm.save() |
183 | 183 |
commission = quotas.get_commission_info(vm, "REBOOT") |
184 |
self.assertEqual({"cyclades.active_cpu": 2,
|
|
185 |
"cyclades.active_ram": 1048576 * 1024}, commission)
|
|
184 |
self.assertEqual({"cyclades.cpu": 2, |
|
185 |
"cyclades.ram": 1048576 * 1024}, commission) |
|
186 | 186 |
vm.operstate = "STARTED" |
187 | 187 |
vm.save() |
188 | 188 |
commission = quotas.get_commission_info(vm, "REBOOT") |
b/snf-cyclades-app/synnefo/quotas/util.py | ||
---|---|---|
51 | 51 |
floating_ips = floating_ips.filter(userid=user) |
52 | 52 |
|
53 | 53 |
# Get resources related with VMs |
54 |
vm_resources = vms.values("userid").annotate(num=Count("id"), |
|
55 |
ram=Sum("flavor__ram"), |
|
56 |
cpu=Sum("flavor__cpu"), |
|
57 |
disk=Sum("flavor__disk")) |
|
54 |
vm_resources = vms.values("userid")\ |
|
55 |
.annotate(num=Count("id"), |
|
56 |
total_ram=Sum("flavor__ram"), |
|
57 |
total_cpu=Sum("flavor__cpu"), |
|
58 |
disk=Sum("flavor__disk")) |
|
58 | 59 |
vm_active_resources = \ |
59 | 60 |
vms.values("userid")\ |
60 | 61 |
.filter(Q(operstate="STARTED") | Q(operstate="BUILD") | |
61 | 62 |
Q(operstate="ERROR"))\ |
62 |
.annotate(active_ram=Sum("flavor__ram"),
|
|
63 |
active_cpu=Sum("flavor__cpu"))
|
|
63 |
.annotate(ram=Sum("flavor__ram"), |
|
64 |
cpu=Sum("flavor__cpu")) |
|
64 | 65 |
|
65 | 66 |
for vm_res in vm_resources.iterator(): |
66 | 67 |
user = vm_res['userid'] |
67 | 68 |
res = {"cyclades.vm": vm_res["num"], |
68 |
"cyclades.cpu": vm_res["cpu"],
|
|
69 |
"cyclades.total_cpu": vm_res["total_cpu"],
|
|
69 | 70 |
"cyclades.disk": 1073741824 * vm_res["disk"], |
70 |
"cyclades.ram": 1048576 * vm_res["ram"]}
|
|
71 |
"cyclades.total_ram": 1048576 * vm_res["total_ram"]}
|
|
71 | 72 |
holdings[user] = res |
72 | 73 |
|
73 | 74 |
for vm_res in vm_active_resources.iterator(): |
74 | 75 |
user = vm_res['userid'] |
75 |
holdings[user]["cyclades.active_cpu"] = vm_res["active_cpu"]
|
|
76 |
holdings[user]["cyclades.active_ram"] = 1048576 * vm_res["active_ram"]
|
|
76 |
holdings[user]["cyclades.cpu"] = vm_res["cpu"]
|
|
77 |
holdings[user]["cyclades.ram"] = 1048576 * vm_res["ram"]
|
|
77 | 78 |
|
78 | 79 |
# Get resources related with networks |
79 | 80 |
net_resources = networks.values("userid")\ |
b/snf-deploy/snfdeploy/fabfile.py | ||
---|---|---|
1260 | 1260 |
snf-manage resource-modify --limit 2 astakos.pending_app |
1261 | 1261 |
snf-manage resource-modify --limit 4 cyclades.vm |
1262 | 1262 |
snf-manage resource-modify --limit 40G cyclades.disk |
1263 |
snf-manage resource-modify --limit 16G cyclades.ram |
|
1264 |
snf-manage resource-modify --limit 8G cyclades.active_ram
|
|
1265 |
snf-manage resource-modify --limit 32 cyclades.cpu |
|
1266 |
snf-manage resource-modify --limit 16 cyclades.active_cpu
|
|
1263 |
snf-manage resource-modify --limit 16G cyclades.total_ram
|
|
1264 |
snf-manage resource-modify --limit 8G cyclades.ram |
|
1265 |
snf-manage resource-modify --limit 32 cyclades.total_cpu
|
|
1266 |
snf-manage resource-modify --limit 16 cyclades.cpu |
|
1267 | 1267 |
snf-manage resource-modify --limit 4 cyclades.network.private |
1268 | 1268 |
snf-manage resource-modify --limit 4 cyclades.floating_ip |
1269 | 1269 |
""" |
Also available in: Unified diff