Merge "Create floating IP on a specific subnet ID"

This commit is contained in:
Jenkins
2015-11-09 19:36:04 +00:00
committed by Gerrit Code Review
2 changed files with 34 additions and 1 deletions

View File

@@ -64,6 +64,10 @@ class CreateFloatingIP(neutronV20.CreateCommand):
parser.add_argument(
'--floating-ip-address',
help=_('IP address of the floating IP'))
parser.add_argument(
'--subnet',
dest='subnet_id',
help=_('Subnet ID on which you want to create the floating IP.'))
def args2body(self, parsed_args):
_network_id = neutronV20.find_resourceid_by_name_or_id(
@@ -72,7 +76,7 @@ class CreateFloatingIP(neutronV20.CreateCommand):
neutronV20.update_dict(parsed_args, body,
['port_id', 'tenant_id',
'fixed_ip_address',
'floating_ip_address'])
'floating_ip_address', 'subnet_id'])
return {self.resource: body}

View File

@@ -85,6 +85,35 @@ class CLITestV20FloatingIpsJSON(test_cli20.CLITestV20Base):
self._test_create_resource(resource, cmd, name, myid, args,
position_names, position_values)
def test_create_floatingip_with_subnet_id(self):
"""Create floatingip: fip1 on a given subnet id."""
resource = 'floatingip'
cmd = fip.CreateFloatingIP(test_cli20.MyApp(sys.stdout), None)
name = 'fip1'
myid = 'myid'
subnet_id = 'mysubnetid'
args = [name, '--subnet', subnet_id]
position_values = [name, subnet_id]
position_names = ['floating_network_id', 'subnet_id']
self._test_create_resource(resource, cmd, name, myid, args,
position_names, position_values)
def test_create_floatingip_with_subnet_id_and_port(self):
"""Create floatingip: fip1 on a given subnet id and port."""
resource = 'floatingip'
cmd = fip.CreateFloatingIP(test_cli20.MyApp(sys.stdout), None)
name = 'fip1'
myid = 'myid'
pid = 'mypid'
subnet_id = 'mysubnetid'
args = [name, '--subnet', subnet_id, '--port-id', pid]
position_values = [name, subnet_id, pid]
position_names = ['floating_network_id', 'subnet_id', 'port_id']
self._test_create_resource(resource, cmd, name, myid, args,
position_names, position_values)
def test_list_floatingips(self):
"""list floatingips: -D."""
resources = 'floatingips'