Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ac1ee026
authored
Aug 25, 2014
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new model for connection template
parent
c06380e5
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
circle/dashboard/models.py
+31
-0
No files found.
circle/dashboard/models.py
View file @
ac1ee026
...
@@ -46,6 +46,7 @@ from acl.models import AclBase
...
@@ -46,6 +46,7 @@ from acl.models import AclBase
from
common.models
import
HumanReadableObject
,
create_readable
,
Encoder
from
common.models
import
HumanReadableObject
,
create_readable
,
Encoder
from
vm.tasks.agent_tasks
import
add_keys
,
del_keys
from
vm.tasks.agent_tasks
import
add_keys
,
del_keys
from
vm.models.instance
import
ACCESS_METHODS
from
.store_api
import
Store
,
NoStoreException
,
NotOkException
from
.store_api
import
Store
,
NoStoreException
,
NotOkException
...
@@ -100,6 +101,19 @@ class Notification(TimeStampedModel):
...
@@ -100,6 +101,19 @@ class Notification(TimeStampedModel):
self
.
message_data
=
None
if
value
is
None
else
value
.
to_dict
()
self
.
message_data
=
None
if
value
is
None
else
value
.
to_dict
()
class
ConnectCommand
(
Model
):
user
=
ForeignKey
(
User
,
related_name
=
'command_set'
)
access_method
=
CharField
(
max_length
=
10
,
choices
=
ACCESS_METHODS
,
verbose_name
=
_
(
'access method'
),
help_text
=
_
(
'Primary remote access method.'
))
application
=
CharField
(
max_length
=
"128"
,
verbose_name
=
_
(
'application'
),
help_text
=
_
(
'Application name to use for this type '
'of connection protocol.'
))
template
=
CharField
(
blank
=
True
,
null
=
True
,
max_length
=
256
,
help_text
=
_
(
'Template for connection command.'
))
class
Profile
(
Model
):
class
Profile
(
Model
):
user
=
OneToOneField
(
User
)
user
=
OneToOneField
(
User
)
preferred_language
=
CharField
(
verbose_name
=
_
(
'preferred language'
),
preferred_language
=
CharField
(
verbose_name
=
_
(
'preferred language'
),
...
@@ -129,6 +143,23 @@ class Profile(Model):
...
@@ -129,6 +143,23 @@ class Profile(Model):
default
=
2048
*
1024
*
1024
,
default
=
2048
*
1024
*
1024
,
help_text
=
_
(
'Disk quota in mebibytes.'
))
help_text
=
_
(
'Disk quota in mebibytes.'
))
def
get_connect_command
(
self
,
instance
,
use_ipv6
=
False
):
""" Generate connection command based on template."""
try
:
command
=
self
.
user
.
command_set
.
get
(
access_method
=
instance
.
access_method
)
except
ConnectCommand
.
DoesNotExist
:
# No template for this protocol return default
return
instance
.
get_connect_command
(
use_ipv6
)
else
:
return
command
.
template
%
{
'port'
:
instance
.
get_connect_port
(
use_ipv6
=
use_ipv6
),
'host'
:
instance
.
get_connect_host
(
use_ipv6
=
use_ipv6
),
'password'
:
instance
.
pw
,
'app'
:
command
.
application
,
'username'
:
'cloud'
}
def
notify
(
self
,
subject
,
template
,
context
=
None
,
valid_until
=
None
,
def
notify
(
self
,
subject
,
template
,
context
=
None
,
valid_until
=
None
,
**
kwargs
):
**
kwargs
):
if
context
is
not
None
:
if
context
is
not
None
:
...
...
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