Merge "Warn on tiny subnet"

This commit is contained in:
Jenkins
2014-07-22 06:27:42 +00:00
committed by Gerrit Code Review
2 changed files with 26 additions and 0 deletions

View File

@@ -159,6 +159,11 @@ class CreateSubnet(neutronV20.CreateCommand):
help=_('CIDR of subnet to create.'))
def args2body(self, parsed_args):
if parsed_args.ip_version == 4 and parsed_args.cidr.endswith('/32'):
self.log.warning(_("An IPv4 subnet with a /32 CIDR will have "
"only one usable IP address so the device "
"attached to it will not have any IP "
"connectivity."))
_network_id = neutronV20.find_resourceid_by_name_or_id(
self.get_client(), 'network', parsed_args.network_id)
body = {'subnet': {'cidr': parsed_args.cidr,

View File

@@ -16,6 +16,8 @@
import sys
from mox3 import mox
from neutronclient.common import exceptions
from neutronclient.neutron.v2_0 import subnet
from neutronclient.tests.unit import test_cli20
@@ -315,6 +317,25 @@ class CLITestV20SubnetJSON(test_cli20.CLITestV20Base):
position_names, position_values,
tenant_id='tenantid')
def test_create_subnet_max_v4_cidr(self):
"""Create subnet: --gateway gateway netid cidr."""
resource = 'subnet'
cmd = subnet.CreateSubnet(test_cli20.MyApp(sys.stdout), None)
name = 'myname'
myid = 'myid'
netid = 'netid'
cidr = '192.168.0.1/32'
gateway = 'gatewayvalue'
args = ['--gateway', gateway, netid, cidr]
position_names = ['ip_version', 'network_id', 'cidr', 'gateway_ip']
position_values = [4, netid, cidr, gateway]
self.mox.StubOutWithMock(cmd.log, 'warning')
cmd.log.warning(mox.IgnoreArg())
self._test_create_resource(resource, cmd, name, myid, args,
position_names, position_values)
self.mox.VerifyAll()
self.mox.UnsetStubs()
def test_list_subnets_detail(self):
"""List subnets: -D."""
resources = "subnets"