Skip to content
This repository was archived by the owner on Nov 29, 2023. It is now read-only.

Commit 59323ed

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Send all options with CreateFloatingIP"
2 parents 75fcafb + 2dd9799 commit 59323ed

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

quantumclient/quantum/v2_0/floatingip.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,14 @@ def add_known_arguments(self, parser):
6969
def args2body(self, parsed_args):
7070
_network_id = quantumv20.find_resourceid_by_name_or_id(
7171
self.get_client(), 'network', parsed_args.floating_network_id)
72-
body = {'floatingip': {
73-
'floating_network_id': _network_id}}
72+
body = {self.resource: {'floating_network_id': _network_id}}
73+
if parsed_args.port_id:
74+
body[self.resource].update({'port_id': parsed_args.port_id})
7475
if parsed_args.tenant_id:
75-
body['floatingip'].update({'tenant_id': parsed_args.tenant_id})
76+
body[self.resource].update({'tenant_id': parsed_args.tenant_id})
77+
if parsed_args.fixed_ip_address:
78+
body[self.resource].update({'fixed_ip_address':
79+
parsed_args.fixed_ip_address})
7680
return body
7781

7882

quantumclient/tests/unit/test_cli20_floatingips.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,25 @@ def test_create_floatingip_and_port(self):
6161
_str = self._test_create_resource(resource, cmd, name, myid, args,
6262
position_names, position_values)
6363

64+
def test_create_floatingip_and_port_and_address(self):
65+
"""Create floatingip: fip1 with a given port and address"""
66+
resource = 'floatingip'
67+
cmd = CreateFloatingIP(MyApp(sys.stdout), None)
68+
name = 'fip1'
69+
myid = 'myid'
70+
pid = 'mypid'
71+
addr = '10.0.0.99'
72+
args = [name, '--port_id', pid, '--fixed_ip_address', addr]
73+
position_names = ['floating_network_id', 'port_id', 'fixed_ip_address']
74+
position_values = [name, pid, addr]
75+
_str = self._test_create_resource(resource, cmd, name, myid, args,
76+
position_names, position_values)
77+
# Test dashed options
78+
args = [name, '--port-id', pid, '--fixed-ip-address', addr]
79+
position_names = ['floating_network_id', 'port-id', 'fixed-ip-address']
80+
_str = self._test_create_resource(resource, cmd, name, myid, args,
81+
position_names, position_values)
82+
6483
def test_list_floatingips(self):
6584
"""list floatingips: -D."""
6685
resources = 'floatingips'

0 commit comments

Comments
 (0)