Revision 7fede91e snf-cyclades-app/synnefo/api/networks.py
b/snf-cyclades-app/synnefo/api/networks.py | ||
---|---|---|
47 | 47 |
from synnefo.api.faults import (BadRequest, Unauthorized, |
48 | 48 |
NetworkInUse, OverLimit) |
49 | 49 |
from synnefo.db.models import Network, Pool |
50 |
|
|
51 | 50 |
from synnefo.logic import backend |
52 | 51 |
from synnefo.settings import MAX_CIDR_BLOCK |
53 | 52 |
|
... | ... | |
83 | 82 |
|
84 | 83 |
|
85 | 84 |
def network_to_dict(network, user_id, detail=True): |
86 |
network_id = str(network.id) if not network.public else 'public' |
|
87 |
d = {'id': network_id, 'name': network.name} |
|
85 |
d = {'id': str(network.id), 'name': network.name} |
|
88 | 86 |
if detail: |
89 | 87 |
d['cidr'] = network.subnet |
90 | 88 |
d['cidr6'] = network.subnet6 |
... | ... | |
95 | 93 |
d['updated'] = util.isoformat(network.updated) |
96 | 94 |
d['created'] = util.isoformat(network.created) |
97 | 95 |
d['status'] = network.state |
96 |
d['public'] = network.public |
|
98 | 97 |
|
99 |
attachments = [util.construct_nic_id(nic) for nic in network.nics.filter(machine__userid= user_id)] |
|
100 |
d['attachments'] = {'values':attachments} |
|
98 |
attachments = [util.construct_nic_id(nic) |
|
99 |
for nic in network.nics.filter(machine__userid=user_id)] |
|
100 |
d['attachments'] = {'values': attachments} |
|
101 | 101 |
return d |
102 | 102 |
|
103 | 103 |
|
Also available in: Unified diff