Revision eb5f7eb0 snf-cyclades-app/synnefo/logic/subnets.py

b/snf-cyclades-app/synnefo/logic/subnets.py
115 115
        if ipversion == 6:
116 116
            raise api.faults.Conflict("Can't allocate an IP Pool in IPv6")
117 117
    elif ipversion == 4:
118
        # Check if the gateway is the first IP of the subnet, in this case
119
        # create a single ip pool
118
        # Check if the gateway is the first IP of the subnet, or the last. In
119
        # that case create a single ip pool.
120 120
        if gateway_ip:
121 121
            if int(gateway_ip) - int(cidr_ip) == 1:
122 122
                allocation_pools = [(gateway_ip + 1, cidr_ip.broadcast - 1)]
123
            elif int(cidr_ip.broadcast) - int(gateway_ip) == 1:
124
                allocation_pools = [(cidr_ip.network + 1, gateway_ip - 1)]
123 125
            else:
124 126
                # If the gateway isn't the first available ip, create two
125 127
                # different ip pools adjacent to said ip
......
232 234
            if not (gateway < start or gateway > end):
233 235
                raise api.faults.Conflict("Gateway cannot be in pool range")
234 236

  
235
    # Check if there is a conflict between the IP Poll ranges
237
    # Check if there is a conflict between the IP Pool ranges
236 238
    end = cidr.network
237 239
    for pool in pool_list:
238 240
        if end >= pool[0]:

Also available in: Unified diff