Revision e440e835 snf-cyclades-app/synnefo/api/networks.py
b/snf-cyclades-app/synnefo/api/networks.py | ||
---|---|---|
54 | 54 |
|
55 | 55 |
log = getLogger('synnefo.api') |
56 | 56 |
|
57 |
urlpatterns = patterns('synnefo.api.networks', |
|
57 |
urlpatterns = patterns( |
|
58 |
'synnefo.api.networks', |
|
58 | 59 |
(r'^(?:/|.json|.xml)?$', 'demux'), |
59 | 60 |
(r'^/detail(?:.json|.xml)?$', 'list_networks', {'detail': True}), |
60 | 61 |
(r'^/(\w+)(?:.json|.xml)?$', 'network_demux'), |
... | ... | |
97 | 98 |
d['public'] = network.public |
98 | 99 |
|
99 | 100 |
attachments = [util.construct_nic_id(nic) |
100 |
for nic in network.nics.filter(machine__userid=user_id)\
|
|
101 |
for nic in network.nics.filter(machine__userid=user_id) |
|
101 | 102 |
.order_by('machine')] |
102 | 103 |
d['attachments'] = {'values': attachments} |
103 | 104 |
return d |
... | ... | |
200 | 201 |
try: |
201 | 202 |
mode, link, mac_prefix, tags = util.values_from_flavor(flavor) |
202 | 203 |
network = Network.objects.create( |
203 |
name=name,
|
|
204 |
userid=user_id,
|
|
205 |
subnet=subnet,
|
|
206 |
subnet6=subnet6,
|
|
207 |
gateway=gateway,
|
|
208 |
gateway6=gateway6,
|
|
209 |
dhcp=dhcp,
|
|
210 |
flavor=flavor,
|
|
211 |
mode=mode,
|
|
212 |
link=link,
|
|
213 |
mac_prefix=mac_prefix,
|
|
214 |
tags=tags,
|
|
215 |
action='CREATE',
|
|
216 |
state='PENDING',
|
|
217 |
serial=serial)
|
|
204 |
name=name, |
|
205 |
userid=user_id, |
|
206 |
subnet=subnet, |
|
207 |
subnet6=subnet6, |
|
208 |
gateway=gateway, |
|
209 |
gateway6=gateway6, |
|
210 |
dhcp=dhcp, |
|
211 |
flavor=flavor, |
|
212 |
mode=mode, |
|
213 |
link=link, |
|
214 |
mac_prefix=mac_prefix, |
|
215 |
tags=tags, |
|
216 |
action='CREATE', |
|
217 |
state='PENDING', |
|
218 |
serial=serial) |
|
218 | 219 |
except EmptyPool: |
219 | 220 |
log.error("Failed to allocate resources for network of type: %s", |
220 | 221 |
flavor) |
... | ... | |
305 | 306 |
if net.machines.all(): # Nics attached on network |
306 | 307 |
raise NetworkInUse('Machines are connected to network.') |
307 | 308 |
|
308 |
|
|
309 | 309 |
net.action = 'DESTROY' |
310 | 310 |
net.save() |
311 | 311 |
|
Also available in: Unified diff