Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f009956d
authored
Jul 13, 2013
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
one: refactor in models
parent
ca125a86
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
one/models.py
+9
-9
No files found.
one/models.py
View file @
f009956d
...
@@ -64,6 +64,10 @@ class UserCloudDetails(models.Model):
...
@@ -64,6 +64,10 @@ class UserCloudDetails(models.Model):
help_text
=
_
(
'Disk quota in mebibytes.'
))
help_text
=
_
(
'Disk quota in mebibytes.'
))
def
reset_keys
(
self
):
def
reset_keys
(
self
):
"""Deprecated. Use reset_ssh_keys instead."""
self
.
reset_ssh_keys
()
def
reset_ssh_keys
(
self
):
"""Delete old SSH key pair and generate new one."""
"""Delete old SSH key pair and generate new one."""
pri
,
pub
=
keygen
()
pri
,
pub
=
keygen
()
self
.
ssh_private_key
=
pri
self
.
ssh_private_key
=
pri
...
@@ -112,16 +116,12 @@ class UserCloudDetails(models.Model):
...
@@ -112,16 +116,12 @@ class UserCloudDetails(models.Model):
def
set_quota
(
sender
,
instance
,
created
,
**
kwargs
):
def
set_quota
(
sender
,
instance
,
created
,
**
kwargs
):
try
:
try
:
if
not
StoreApi
.
userexist
(
instance
.
user
.
username
):
if
not
StoreApi
.
userexist
(
instance
.
user
.
username
):
try
:
password
=
instance
.
smb_password
password
=
instance
.
smb_password
quota
=
instance
.
disk_quota
*
1024
quota
=
instance
.
disk_quota
*
1024
key_list
=
[
key
.
key
for
key
in
instance
.
user
.
sshkey_set
.
all
()]
key_list
=
[
k
.
key
for
k
in
instance
.
user
.
sshkey_set
.
all
()]
except
:
pass
# Create user
# Create user
if
not
StoreApi
.
createuser
(
instance
.
user
.
username
,
password
,
StoreApi
.
createuser
(
instance
.
user
.
username
,
password
,
key_list
,
key_list
,
quota
):
quota
)
pass
else
:
else
:
StoreApi
.
set_quota
(
instance
.
user
.
username
,
StoreApi
.
set_quota
(
instance
.
user
.
username
,
instance
.
disk_quota
*
1024
)
instance
.
disk_quota
*
1024
)
...
@@ -133,7 +133,7 @@ post_save.connect(set_quota, sender=UserCloudDetails)
...
@@ -133,7 +133,7 @@ post_save.connect(set_quota, sender=UserCloudDetails)
def
reset_keys
(
sender
,
instance
,
created
,
**
kwargs
):
def
reset_keys
(
sender
,
instance
,
created
,
**
kwargs
):
if
created
:
if
created
:
instance
.
reset_smb
()
instance
.
reset_smb
()
instance
.
reset_keys
()
instance
.
reset_
ssh_
keys
()
post_save
.
connect
(
reset_keys
,
sender
=
UserCloudDetails
)
post_save
.
connect
(
reset_keys
,
sender
=
UserCloudDetails
)
...
@@ -148,7 +148,7 @@ class OpenSshKeyValidator(object):
...
@@ -148,7 +148,7 @@ class OpenSshKeyValidator(object):
def
__call__
(
self
,
value
):
def
__call__
(
self
,
value
):
try
:
try
:
value
=
"
%
s comment"
%
value
value
=
value
+
' comment'
type
,
key_string
,
comment
=
value
.
split
(
None
,
2
)
type
,
key_string
,
comment
=
value
.
split
(
None
,
2
)
if
type
not
in
self
.
valid_types
:
if
type
not
in
self
.
valid_types
:
raise
ValidationError
(
_
(
'OpenSSH key type
%
s is not '
raise
ValidationError
(
_
(
'OpenSSH key type
%
s is not '
...
...
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