Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
d4aef292
authored
May 22, 2013
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
one: started refactoring model
parent
41694da4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
11 deletions
+8
-11
one/models.py
+8
-11
No files found.
one/models.py
View file @
d4aef292
...
...
@@ -53,9 +53,9 @@ class UserCloudDetails(models.Model):
'accessing store from Linux.'
))
ssh_private_key
=
models
.
TextField
(
verbose_name
=
_
(
'SSH key (private)'
),
blank
=
True
,
help_text
=
_
(
'Generated SSH private
key
'
'
for accessing store from
'
'Linux.'
))
help_text
=
_
(
'Generated SSH private '
'
key for accessing
'
'
store from
Linux.'
))
share_quota
=
models
.
IntegerField
(
verbose_name
=
_
(
'share quota'
),
default
=
0
)
instance_quota
=
models
.
IntegerField
(
verbose_name
=
_
(
'instance quota'
),
...
...
@@ -82,11 +82,10 @@ class UserCloudDetails(models.Model):
self
.
smb_password
=
pwgen
()
def
get_weighted_instance_count
(
self
):
c
=
0
for
i
in
self
.
user
.
instance_set
.
all
():
if
i
.
state
in
(
'ACTIVE'
,
'PENDING'
,
):
c
=
c
+
i
.
template
.
instance_type
.
credit
return
c
credits
=
[
i
.
template
.
instance_type
.
credit
for
i
in
self
.
user
.
instance_set
.
all
()
if
i
.
state
in
(
'ACTIVE'
,
'PENDING'
,
)]
return
sum
(
credits
)
def
get_instance_pc
(
self
):
return
100
*
self
.
get_weighted_instance_count
()
/
self
.
instance_quota
...
...
@@ -106,9 +105,7 @@ def set_quota(sender, instance, created, **kwargs):
try
:
password
=
instance
.
smb_password
quota
=
instance
.
disk_quota
*
1024
key_list
=
[]
for
key
in
instance
.
user
.
sshkey_set
.
all
():
key_list
.
append
(
key
.
key
)
key_list
=
[
key
.
key
for
key
in
instance
.
user
.
sshkey_set
.
all
()]
except
:
pass
# Create user
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment