diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-09-10 23:09:22 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-09-10 23:09:22 +0000 |
| commit | 59323edf4e75920428bec89fa62c70591f557dd8 (patch) | |
| tree | dfdc119474f32567325feade798dd2cab290a717 /quantumclient | |
| parent | 75fcafbbc6872be61dab3cbdd3c9f63dec3cf09c (diff) | |
| parent | 2dd97991dff0831689fdad29d2ff2b942bf75ae9 (diff) | |
| download | python-neutronclient-59323edf4e75920428bec89fa62c70591f557dd8.tar.gz | |
Merge "Send all options with CreateFloatingIP"
Diffstat (limited to 'quantumclient')
| -rw-r--r-- | quantumclient/quantum/v2_0/floatingip.py | 10 | ||||
| -rw-r--r-- | quantumclient/tests/unit/test_cli20_floatingips.py | 19 |
2 files changed, 26 insertions, 3 deletions
diff --git a/quantumclient/quantum/v2_0/floatingip.py b/quantumclient/quantum/v2_0/floatingip.py index d5d2181..002384a 100644 --- a/quantumclient/quantum/v2_0/floatingip.py +++ b/quantumclient/quantum/v2_0/floatingip.py @@ -69,10 +69,14 @@ class CreateFloatingIP(CreateCommand): def args2body(self, parsed_args): _network_id = quantumv20.find_resourceid_by_name_or_id( self.get_client(), 'network', parsed_args.floating_network_id) - body = {'floatingip': { - 'floating_network_id': _network_id}} + body = {self.resource: {'floating_network_id': _network_id}} + if parsed_args.port_id: + body[self.resource].update({'port_id': parsed_args.port_id}) if parsed_args.tenant_id: - body['floatingip'].update({'tenant_id': parsed_args.tenant_id}) + body[self.resource].update({'tenant_id': parsed_args.tenant_id}) + if parsed_args.fixed_ip_address: + body[self.resource].update({'fixed_ip_address': + parsed_args.fixed_ip_address}) return body diff --git a/quantumclient/tests/unit/test_cli20_floatingips.py b/quantumclient/tests/unit/test_cli20_floatingips.py index 9aeb1e2..e48d29e 100644 --- a/quantumclient/tests/unit/test_cli20_floatingips.py +++ b/quantumclient/tests/unit/test_cli20_floatingips.py @@ -61,6 +61,25 @@ class CLITestV20FloatingIps(CLITestV20Base): _str = self._test_create_resource(resource, cmd, name, myid, args, position_names, position_values) + def test_create_floatingip_and_port_and_address(self): + """Create floatingip: fip1 with a given port and address""" + resource = 'floatingip' + cmd = CreateFloatingIP(MyApp(sys.stdout), None) + name = 'fip1' + myid = 'myid' + pid = 'mypid' + addr = '10.0.0.99' + args = [name, '--port_id', pid, '--fixed_ip_address', addr] + position_names = ['floating_network_id', 'port_id', 'fixed_ip_address'] + position_values = [name, pid, addr] + _str = self._test_create_resource(resource, cmd, name, myid, args, + position_names, position_values) + # Test dashed options + args = [name, '--port-id', pid, '--fixed-ip-address', addr] + position_names = ['floating_network_id', 'port-id', 'fixed-ip-address'] + _str = self._test_create_resource(resource, cmd, name, myid, args, + position_names, position_values) + def test_list_floatingips(self): """list floatingips: -D.""" resources = 'floatingips' |
