Revision af6a3bc5 snf-cyclades-app/synnefo/api/management/commands/network-create.py
b/snf-cyclades-app/synnefo/api/management/commands/network-create.py | ||
---|---|---|
36 | 36 |
from django.core.management.base import BaseCommand, CommandError |
37 | 37 |
|
38 | 38 |
from synnefo.db.models import Network, Backend |
39 |
from synnefo.api.util import network_link_from_type, validate_network_size
|
|
39 |
from synnefo.api.util import net_resources, validate_network_size
|
|
40 | 40 |
from synnefo.logic.backend import create_network |
41 | 41 |
from synnefo import settings |
42 | 42 |
|
... | ... | |
105 | 105 |
|
106 | 106 |
name = options['name'] |
107 | 107 |
subnet = options['subnet'] |
108 |
typ = options['type']
|
|
108 |
net_type = options['type']
|
|
109 | 109 |
backend_id = options['backend_id'] |
110 | 110 |
public = options['public'] |
111 | 111 |
|
... | ... | |
115 | 115 |
raise CommandError("Subnet is required") |
116 | 116 |
if public and not backend_id: |
117 | 117 |
raise CommandError("backend-id is required") |
118 |
if public and not typ=='PUBLIC_ROUTED':
|
|
118 |
if public and not net_type == 'PUBLIC_ROUTED':
|
|
119 | 119 |
raise CommandError("Invalid type for public network") |
120 | 120 |
if backend_id and not public: |
121 | 121 |
raise CommandError("Private networks must be created to" |
... | ... | |
130 | 130 |
except Backend.DoesNotExist: |
131 | 131 |
raise CommandError("Backend not found in DB") |
132 | 132 |
|
133 |
link = network_link_from_type(typ)
|
|
133 |
link, mac_prefix = net_resources(net_type)
|
|
134 | 134 |
|
135 | 135 |
subnet, gateway, subnet6, gateway6 = validate_network_info(options) |
136 | 136 |
|
... | ... | |
143 | 143 |
subnet=subnet, |
144 | 144 |
gateway=gateway, |
145 | 145 |
dhcp=options['dhcp'], |
146 |
type=options['type'],
|
|
146 |
type=net_type,
|
|
147 | 147 |
public=public, |
148 | 148 |
link=link, |
149 |
mac_prefix=mac_prefix, |
|
149 | 150 |
gateway6=gateway6, |
150 | 151 |
subnet6=subnet6, |
151 | 152 |
state='PENDING') |
Also available in: Unified diff