Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
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
490e1dac
authored
Aug 27, 2014
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: handle IntegrityError exception at allocate_vnc
parent
02ba97dc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
circle/vm/models/instance.py
+11
-2
No files found.
circle/vm/models/instance.py
View file @
490e1dac
...
...
@@ -32,6 +32,7 @@ from django.core.exceptions import PermissionDenied
from
django.db.models
import
(
BooleanField
,
CharField
,
DateTimeField
,
IntegerField
,
ForeignKey
,
Manager
,
ManyToManyField
,
permalink
,
SET_NULL
,
TextField
)
from
django.db
import
IntegrityError
from
django.dispatch
import
Signal
from
django.utils
import
timezone
from
django.utils.translation
import
ugettext_lazy
as
_
,
ugettext_noop
...
...
@@ -926,8 +927,16 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
def
allocate_vnc_port
(
self
):
if
self
.
vnc_port
is
None
:
self
.
vnc_port
=
find_unused_vnc_port
()
self
.
save
()
while
True
:
try
:
self
.
vnc_port
=
find_unused_vnc_port
()
self
.
save
()
except
IntegrityError
:
# Another thread took this port get another one
logger
.
debug
(
"Port
%
s is in use."
,
self
.
vnc_port
)
pass
else
:
break
def
yield_vnc_port
(
self
):
if
self
.
vnc_port
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