diff --git a/sahara/service/validations/base.py b/sahara/service/validations/base.py index 6a50fa70..9ce0f1dc 100644 --- a/sahara/service/validations/base.py +++ b/sahara/service/validations/base.py @@ -133,7 +133,16 @@ def check_flavor_exists(flavor_id): def check_floatingip_pool_exists(ng_name, pool_id): - if not nova.get_network(id=pool_id): + network = None + if CONF.use_neutron: + network = nova.get_network(id=pool_id) + else: + for net in nova.client().floating_ip_pools.list(): + if net.name == pool_id: + network = net.name + break + + if not network: raise ex.InvalidException("Floating IP pool %s for node group " "'%s' not found" % (pool_id, ng_name)) diff --git a/sahara/tests/unit/service/validation/utils.py b/sahara/tests/unit/service/validation/utils.py index c596df36..74927a81 100644 --- a/sahara/tests/unit/service/validation/utils.py +++ b/sahara/tests/unit/service/validation/utils.py @@ -64,6 +64,10 @@ def _get_network(**kwargs): return 'OK' +def _get_fl_ip_pool_list(): + return [FakeNetwork("d9a3bebc-f788-4b81-9a93-aa048022c1ca")] + + def _get_heat_stack_list(): return [FakeStack('test-heat')] @@ -73,6 +77,11 @@ class FakeStack(object): self.stack_name = name +class FakeNetwork(object): + def __init__(self, name): + self.name = name + + class FakeFlavor(object): def __init__(self, id): self.id = id @@ -124,6 +133,7 @@ def start_patch(patch_templates=True): nova().flavors.list.side_effect = _get_flavors_list nova().keypairs.get.side_effect = _get_keypair nova().networks.find.side_effect = _get_network + nova().floating_ip_pools.list.side_effect = _get_fl_ip_pool_list heat = heat_p.start() heat().stacks.list.side_effect = _get_heat_stack_list