Revision 53162472 snf-cyclades-app/synnefo/api/management/commands/subnet-list.py
b/snf-cyclades-app/synnefo/api/management/commands/subnet-list.py | ||
---|---|---|
36 | 36 |
from snf_django.management.commands import ListCommand, CommandError |
37 | 37 |
from synnefo.settings import (CYCLADES_SERVICE_TOKEN as ASTAKOS_TOKEN, |
38 | 38 |
ASTAKOS_BASE_URL) |
39 |
from synnefo.db.models import Subnet, Network
|
|
39 |
from synnefo.db.models import Subnet |
|
40 | 40 |
|
41 | 41 |
from logging import getLogger |
42 | 42 |
log = getLogger(__name__) |
... | ... | |
66 | 66 |
help="List only subnets that have DHCP/SLAC enabled"), |
67 | 67 |
) |
68 | 68 |
|
69 |
def get_userid(sub): |
|
70 |
return Network.objects.get(id=sub.network.id).userid |
|
71 |
|
|
72 |
def get_network(net): |
|
73 |
return Network.objects.get(id=net.network.id).id |
|
74 |
|
|
75 | 69 |
object_class = Subnet |
76 | 70 |
astakos_url = ASTAKOS_BASE_URL |
77 | 71 |
astakos_token = ASTAKOS_TOKEN |
78 | 72 |
|
79 | 73 |
FIELDS = { |
80 | 74 |
"id": ("id", "ID of the subnet"), |
81 |
"network": (get_network, "ID of the network the subnet belongs to"),
|
|
75 |
"network": ("network_id", "ID of the network the subnet belongs to"),
|
|
82 | 76 |
"name": ("name", "Name of the subnet"), |
83 |
"user.uuid": (get_userid, "The UUID of the subnet's owner"),
|
|
77 |
"user.uuid": ("network.userid", "The UUID of the subnet's owner"),
|
|
84 | 78 |
"cidr": ("cidr", "The CIDR of the subnet"), |
85 | 79 |
"ipversion": ("ipversion", "The IP version of the subnet"), |
86 | 80 |
"gateway": ("gateway", "The gateway IP of the subnet"), |
Also available in: Unified diff