Create floating IP on a specific subnet ID
Implemented optional parameter (with dashed arguments only) for python-neutronclient to create floating IP on a subnet ID. Created corresponding unit test cases. Closes-Bug: #1482496 Change-Id: Iea9175bd534fdfd1bbfa6819f8ef6f45fcbcfa5e
This commit is contained in:
@@ -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}
|
||||
|
||||
|
||||
|
@@ -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'
|
||||
|
Reference in New Issue
Block a user