Make "multi_host" True when it is set to 'T' in network_create.

Fixes bug 1161297
Even if creating a network with the "--multi_host=T", the "multi_host"
property of the new network is still "False".
This is because nova server interprets 'T' to "False".
This patch fixes the problem.

Change-Id: I171c7dc72cb515c47ea106558080eafa10dee873
This commit is contained in:
Haiwei Xu 2013-03-28 19:42:00 +09:00
parent 0fc4e12043
commit ea94b09ad7
2 changed files with 29 additions and 0 deletions

View File

@ -26,6 +26,7 @@ import sys
import time import time
from novaclient import exceptions from novaclient import exceptions
from novaclient.openstack.common import strutils
from novaclient.openstack.common import timeutils from novaclient.openstack.common import timeutils
from novaclient import utils from novaclient import utils
from novaclient.v1_1 import availability_zones from novaclient.v1_1 import availability_zones
@ -708,6 +709,9 @@ def do_network_create(cs, args):
raise exceptions.CommandError( raise exceptions.CommandError(
"Must specify eith fixed_range_v4 or fixed_range_v6") "Must specify eith fixed_range_v4 or fixed_range_v6")
kwargs = _filter_network_create_options(args) kwargs = _filter_network_create_options(args)
if args.multi_host is not None:
kwargs['multi_host'] = bool(args.multi_host == 'T' or
strutils.bool_from_string(args.multi_host))
cs.networks.create(**kwargs) cs.networks.create(**kwargs)

View File

@ -1088,6 +1088,31 @@ class ShellTest(utils.TestCase):
cmd = 'network-create 10.0.1.0' cmd = 'network-create 10.0.1.0'
self.assertRaises(exceptions.CommandError, self.run_command, cmd) self.assertRaises(exceptions.CommandError, self.run_command, cmd)
def test_network_create_multi_host(self):
self.run_command('network-create --fixed-range-v4 192.168.0.0/24'
' --multi-host=T new_network')
body = {'network': {'cidr': '192.168.0.0/24', 'label': 'new_network',
'multi_host': True}}
self.assert_called('POST', '/os-networks', body)
self.run_command('network-create --fixed-range-v4 192.168.0.0/24'
' --multi-host=True new_network')
body = {'network': {'cidr': '192.168.0.0/24', 'label': 'new_network',
'multi_host': True}}
self.assert_called('POST', '/os-networks', body)
self.run_command('network-create --fixed-range-v4 192.168.0.0/24'
' --multi-host=1 new_network')
body = {'network': {'cidr': '192.168.0.0/24', 'label': 'new_network',
'multi_host': True}}
self.assert_called('POST', '/os-networks', body)
self.run_command('network-create --fixed-range-v4 192.168.1.0/24'
' --multi-host=F new_network')
body = {'network': {'cidr': '192.168.1.0/24', 'label': 'new_network',
'multi_host': False}}
self.assert_called('POST', '/os-networks', body)
def test_add_fixed_ip(self): def test_add_fixed_ip(self):
self.run_command('add-fixed-ip sample-server 1') self.run_command('add-fixed-ip sample-server 1')
self.assert_called('POST', '/servers/1234/action', self.assert_called('POST', '/servers/1234/action',