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
74b83896
authored
Nov 25, 2013
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: extract vnc port search
parent
85f074a6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
7 deletions
+10
-7
circle/vm/models.py
+10
-7
No files found.
circle/vm/models.py
View file @
74b83896
...
@@ -39,6 +39,15 @@ pre_state_changed = Signal(providing_args=["new_state"])
...
@@ -39,6 +39,15 @@ pre_state_changed = Signal(providing_args=["new_state"])
post_state_changed
=
Signal
(
providing_args
=
[
"new_state"
])
post_state_changed
=
Signal
(
providing_args
=
[
"new_state"
])
def
find_unused_vnc_port
():
used
=
Instance
.
objects
.
values_list
(
'vnc_port'
,
flat
=
True
)
for
p
in
xrange
(
*
VNC_PORT_RANGE
):
if
p
not
in
used
:
return
p
else
:
raise
Exception
(
"No unused port could be found for VNC."
)
class
InstanceActiveManager
(
Manager
):
class
InstanceActiveManager
(
Manager
):
def
get_query_set
(
self
):
def
get_query_set
(
self
):
...
@@ -669,13 +678,7 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
...
@@ -669,13 +678,7 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
# Find unused port for VNC
# Find unused port for VNC
if
self
.
vnc_port
is
None
:
if
self
.
vnc_port
is
None
:
used
=
Instance
.
objects
.
values_list
(
'vnc_port'
,
flat
=
True
)
self
.
vnc_port
=
find_unused_vnc_port
()
for
p
in
xrange
(
*
VNC_PORT_RANGE
):
if
p
not
in
used
:
self
.
vnc_port
=
p
break
else
:
raise
Exception
(
"No unused port could be found for VNC."
)
# Schedule
# Schedule
if
self
.
node
is
None
:
if
self
.
node
is
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