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
d039ad8a
authored
Sep 18, 2013
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: make the employed scheduler a config parameter
parent
a262e19a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
10 deletions
+12
-10
circle/circle/settings/base.py
+3
-1
circle/manager/scheduler.py
+3
-5
circle/vm/models.py
+6
-4
No files found.
circle/circle/settings/base.py
View file @
d039ad8a
...
@@ -298,6 +298,8 @@ CRISPY_TEMPLATE_PACK = 'bootstrap3'
...
@@ -298,6 +298,8 @@ CRISPY_TEMPLATE_PACK = 'bootstrap3'
# format: id: (name, port, protocol)
# format: id: (name, port, protocol)
VM_ACCESS_PROTOCOLS
=
loads
(
get_env_variable
(
'DJANGO_VM_ACCESS_PROTOCOLS'
,
VM_ACCESS_PROTOCOLS
=
loads
(
get_env_variable
(
'DJANGO_VM_ACCESS_PROTOCOLS'
,
'''{"nx": ["nx", 22, "tcp"],
'''{"nx": ["nx", 22, "tcp"],
"rdp": ["rdp", 3389, "tcp"],
"rdp": ["rdp", 3389, "tcp"],
"ssh": ["ssh", 22, "tcp"]}'''
))
"ssh": ["ssh", 22, "tcp"]}'''
))
VM_SCHEDULER
=
'manager.scheduler'
circle/manager/scheduler.py
View file @
d039ad8a
def
get_node
(
instance
):
def
get_node
(
instance
,
nodes
):
''' Select a node for an hosting an instance
''' Select a node for hosting an instance based on its requirements.
based on requirements.
'''
'''
# Return first Node or None
# Return first Node or None
models
=
__import__
(
'vm.models'
)
try
:
try
:
return
models
.
models
.
Node
.
objects
.
all
()
[
0
]
return
nodes
[
0
]
except
:
except
:
return
None
return
None
circle/vm/models.py
View file @
d039ad8a
from
datetime
import
timedelta
from
datetime
import
timedelta
from
importlib
import
import_module
import
django.conf
import
logging
import
logging
import
django.conf.settings
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
django.db
import
models
from
django.db
import
models
from
django.db.models.signals
import
pre_delete
from
django.db.models.signals
import
pre_delete
...
@@ -13,12 +14,13 @@ from netaddr import EUI
...
@@ -13,12 +14,13 @@ from netaddr import EUI
from
.
import
tasks
from
.
import
tasks
from
firewall.models
import
Vlan
,
Host
from
firewall.models
import
Vlan
,
Host
from
manager
import
vm_manager
,
scheduler
from
manager
import
vm_manager
from
storage.models
import
Disk
from
storage.models
import
Disk
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
pwgen
=
User
.
objects
.
make_random_password
pwgen
=
User
.
objects
.
make_random_password
scheduler
=
import_module
(
name
=
django
.
conf
.
settings
.
VM_SCHEDULER
)
ACCESS_PROTOCOLS
=
django
.
conf
.
settings
.
VM_ACCESS_PROTOCOLS
ACCESS_PROTOCOLS
=
django
.
conf
.
settings
.
VM_ACCESS_PROTOCOLS
ACCESS_METHODS
=
[(
k
,
ap
[
0
])
for
k
,
ap
in
ACCESS_PROTOCOLS
.
iteritems
()]
ACCESS_METHODS
=
[(
k
,
ap
[
0
])
for
k
,
ap
in
ACCESS_PROTOCOLS
.
iteritems
()]
...
@@ -443,7 +445,7 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
...
@@ -443,7 +445,7 @@ class Instance(BaseResourceConfigModel, TimeStampedModel):
# Schedule
# Schedule
act
.
update_state
(
"PENDING"
)
act
.
update_state
(
"PENDING"
)
self
.
node
=
scheduler
.
get_node
(
self
)
self
.
node
=
scheduler
.
get_node
(
self
,
Node
.
objects
.
all
()
)
self
.
save
()
self
.
save
()
# Create virtual images
# Create virtual images
...
...
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