Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
5470313f
Commit
5470313f
authored
Dec 18, 2013
by
Christos Stavrakakis
Browse files
cyclades: Do not prefetch related in get()
parent
1ad655cd
Changes
3
Hide whitespace changes
Inline
Side-by-side
snf-cyclades-app/synnefo/api/subnets.py
View file @
5470313f
...
...
@@ -164,7 +164,7 @@ def create_subnet(request):
def
get_subnet
(
request
,
sub_id
):
"""Show info of a specific subnet"""
user_id
=
request
.
user_uniq
subnet
=
subnets
.
get_subnet
(
sub_id
,
prefetch_related
=
True
)
subnet
=
subnets
.
get_subnet
(
sub_id
)
if
(
subnet
.
network
.
userid
!=
user_id
)
and
(
subnet
.
network
.
public
is
False
):
raise
api
.
faults
.
Unauthorized
(
"You're not allowed to view this subnet"
)
...
...
snf-cyclades-app/synnefo/api/util.py
View file @
5470313f
...
...
@@ -222,7 +222,7 @@ def get_network(network_id, user_id, for_update=False, non_deleted=False):
try
:
network_id
=
int
(
network_id
)
objects
=
Network
.
objects
.
prefetch_related
(
"subnets"
)
objects
=
Network
.
objects
if
for_update
:
objects
=
objects
.
select_for_update
()
network
=
objects
.
get
(
Q
(
userid
=
user_id
)
|
Q
(
public
=
True
),
...
...
snf-cyclades-app/synnefo/logic/subnets.py
View file @
5470313f
...
...
@@ -148,14 +148,11 @@ def _create_subnet(network_id, user_id, cidr, name, ipversion=4, gateway=None,
return
sub
def
get_subnet
(
sub_id
,
prefetch_related
=
False
):
def
get_subnet
(
sub_id
):
"""Show info of a specific subnet"""
log
.
debug
(
'get_subnet %s'
,
sub_id
)
try
:
subnets
=
Subnet
.
objects
if
prefetch_related
:
subnets
=
subnets
.
select_related
(
"network"
)
subnets
=
subnets
.
prefetch_related
(
"ip_pools"
)
return
subnets
.
get
(
id
=
sub_id
)
except
Subnet
.
DoesNotExist
:
raise
api
.
faults
.
ItemNotFound
(
"Subnet not found"
)
...
...
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