Commit aefe2ed3 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

cyclades: Optimize *-list commands

Use prefetch_related and select-related to importive the DB queries that
are generated by *-list snf-manage commands.
parent ff276c93
......@@ -61,6 +61,8 @@ class Command(ListCommand):
)
object_class = Network
select_related = []
prefetch_related = ["subnets"]
deleted_field = "deleted"
user_uuid_field = "userid"
astakos_url = ASTAKOS_BASE_URL
......
......@@ -49,15 +49,10 @@ class Command(ListCommand):
user_uuid_field = "userid"
astakos_url = ASTAKOS_BASE_URL
astakos_token = ASTAKOS_TOKEN
prefetch_related = ["ips"]
def get_fixed_ips(ip):
def labels((a, b)):
return str({"subnet": b, "ip_address": str(a)})
lista = ip.get_ip_addresses_subnets()
lista = map(labels, lista)
return " ".join(lista)
def get_fixed_ips(port):
return ",".join(port.ips.values_list("address", flat=True))
FIELDS = {
"id": ("id", "The ID of the port"),
......
......@@ -41,6 +41,7 @@ log = getLogger(__name__)
class Command(ListCommand):
help = "List Floating IPs"
object_class = IPAddress
select_related = ["nic"]
deleted_field = "deleted"
user_uuid_field = "userid"
astakos_url = ASTAKOS_BASE_URL
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment