Revision 8646e606
b/snf-cyclades-app/synnefo/api/management/commands/subnet-create.py | ||
---|---|---|
72 | 72 |
" The IP must be inside the CIDR range and cannot be the" |
73 | 73 |
" subnet or broadcast IP. If no value is specified, the" |
74 | 74 |
" first available IP of the subnet will be used."), |
75 |
make_option("--dhcp", action="store_true", dest="dhcp", default=True, |
|
75 |
make_option("--no-dhcp", action="store_true", dest="dhcp", |
|
76 |
default=False, |
|
76 | 77 |
help="True/False value for DHCP/SLAAC. True by default."), |
77 | 78 |
make_option("--dns", dest="dns", |
78 | 79 |
help="DNS nameservers to be used by the VMs in the subnet." |
... | ... | |
92 | 93 |
cidr = options["cidr"] |
93 | 94 |
|
94 | 95 |
if not network_id: |
95 |
raise CommandError("network_id is mandatory")
|
|
96 |
raise CommandError("network-id is mandatory")
|
|
96 | 97 |
if not cidr: |
97 | 98 |
raise CommandError("cidr is mandatory") |
98 | 99 |
|
99 | 100 |
user_id = common.get_network(network_id).userid |
100 | 101 |
name = options["name"] |
101 | 102 |
allocation_pools = options["allocation_pools"] |
102 |
ipversion = int(options["ipversion"])
|
|
103 |
ipversion = options["ipversion"]
|
|
103 | 104 |
if not ipversion: |
104 | 105 |
ipversion = 4 |
106 |
else: |
|
107 |
try: |
|
108 |
ipversion = int(ipversion) |
|
109 |
except ValueError: |
|
110 |
raise CommandError("ip-version must be 4 or 6") |
|
111 |
|
|
105 | 112 |
gateway = options["gateway"] |
106 | 113 |
if not gateway: |
107 | 114 |
gateway = "" |
108 | 115 |
dhcp = options["dhcp"] |
109 |
if not dhcp: |
|
110 |
dhcp = True |
|
116 |
dhcp = False if dhcp else True |
|
111 | 117 |
dns = options["dns"] |
112 | 118 |
host_routes = options["host_routes"] |
113 | 119 |
|
b/snf-cyclades-app/synnefo/api/subnets.py | ||
---|---|---|
177 | 177 |
|
178 | 178 |
name = subnet.get("name", None) |
179 | 179 |
|
180 |
subnet_dict = subnet_to_dict(subnets.update_subnet(sub_id, name)) |
|
180 |
subnet_dict = subnet_to_dict(subnets.update_subnet(sub_id, name, user_id))
|
|
181 | 181 |
data = json.dumps({'subnet': subnet_dict}) |
182 | 182 |
return HttpResponse(data, status=200) |
183 | 183 |
|
b/snf-cyclades-app/synnefo/logic/subnets.py | ||
---|---|---|
129 | 129 |
else: |
130 | 130 |
# If the gateway isn't the first available ip, create two different |
131 | 131 |
# ip pools adjacent to said ip |
132 |
allocation_pools.append([cidr_ip.network + 1, gateway_ip - 1])
|
|
133 |
allocation_pools.append([gateway_ip + 1, cidr_ip.broadcast - 1])
|
|
132 |
allocation_pools = (([cidr_ip.network + 1, gateway_ip - 1]),
|
|
133 |
([gateway_ip + 1, cidr_ip.broadcast - 1]))
|
|
134 | 134 |
|
135 | 135 |
if allocation_pools: |
136 | 136 |
create_ip_pools(allocation_pools, cidr_ip, sub) |
... | ... | |
158 | 158 |
|
159 | 159 |
|
160 | 160 |
@transaction.commit_on_success |
161 |
def update_subnet(sub_id, name): |
|
161 |
def update_subnet(sub_id, name, user_id):
|
|
162 | 162 |
"""Update the fields of a subnet |
163 | 163 |
Only the name can be updated |
164 | 164 |
|
... | ... | |
170 | 170 |
except: |
171 | 171 |
raise api.faults.ItemNotFound("Subnet not found") |
172 | 172 |
|
173 |
if user_id != subnet.network.userid: |
|
174 |
raise api.faults.Unauthorized("Unauthorized operation") |
|
175 |
|
|
173 | 176 |
check_name_length(name) |
174 | 177 |
|
175 | 178 |
subnet.name = name |
Also available in: Unified diff