Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
synnefo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
itminedu
synnefo
Commits
01f90a77
Commit
01f90a77
authored
Dec 19, 2012
by
Christos Stavrakakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bugs in models methods
parent
977b9994
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
snf-cyclades-app/synnefo/db/models.py
snf-cyclades-app/synnefo/db/models.py
+11
-3
No files found.
snf-cyclades-app/synnefo/db/models.py
View file @
01f90a77
...
...
@@ -155,6 +155,9 @@ class Backend(models.Model):
"with backend: %s"
%
self
)
else
:
# ON_DELETE = SET NULL
for
vm
in
self
.
virtual_machines
.
all
():
vm
.
backend
=
None
vm
.
save
()
self
.
virtual_machines
.
all
().
backend
=
None
# Remove BackendNetworks of this Backend.
# Do not use networks.all().delete(), since delete() method of
...
...
@@ -168,8 +171,11 @@ class Backend(models.Model):
if
not
self
.
pk
:
# Generate a unique index for the Backend
indexes
=
Backend
.
objects
.
all
().
values_list
(
'index'
,
flat
=
True
)
first_free
=
[
x
for
x
in
xrange
(
0
,
16
)
if
x
not
in
indexes
][
0
]
self
.
index
=
first_free
try
:
first_free
=
[
x
for
x
in
xrange
(
0
,
16
)
if
x
not
in
indexes
][
0
]
self
.
index
=
first_free
except
IndexError
:
raise
Exception
(
"Can not create more than 16 backends"
)
# A backend job may be in one of the following possible states
...
...
@@ -520,7 +526,9 @@ class Network(models.Model):
backends
=
[
backend
]
if
backend
else
Backend
.
objects
.
all
()
for
backend
in
backends
:
BackendNetwork
.
objects
.
create
(
backend
=
backend
,
network
=
self
)
if
not
BackendNetwork
.
objects
.
filter
(
backend
=
backend
,
network
=
self
)
\
.
exists
():
BackendNetwork
.
objects
.
create
(
backend
=
backend
,
network
=
self
)
def
get_pool
(
self
):
if
not
self
.
pool_id
:
...
...
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