Merge "'network-exists' validator removed"

This commit is contained in:
Jenkins 2017-04-21 15:36:18 +00:00 committed by Gerrit Code Review
commit b2baad1340
4 changed files with 48 additions and 33 deletions

View File

@ -0,0 +1,16 @@
# Copyright 2017: Mirantis Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
pass

View File

@ -373,23 +373,6 @@ def image_valid_on_flavor(config, clients, deployment, flavor_name,
return ValidationResult(False, message)
@validator
def network_exists(config, clients, deployment, network_name):
"""Validator checks that network with network_name exist."""
network = config.get("args", {}).get(network_name, "private")
networks = [net.label for net in
clients.nova().networks.list()]
if network not in networks:
message = _("Network with name %(network)s not found. "
"Available networks: %(networks)s") % {
"network": network,
"networks": networks
}
return ValidationResult(False, message)
@validator
def external_network_exists(config, clients, deployment, network_name):
"""Validator checks that external network with given name exists."""

View File

@ -0,0 +1,16 @@
# Copyright 2017: Mirantis Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
pass

View File

@ -587,22 +587,22 @@ class ValidatorsTestCase(test.TestCase):
result = validator(config, clients, None)
self.assertFalse(result.is_valid, result.msg)
def test_network_exists(self):
validator = self._unwrap_validator(validation.network_exists, "net")
net1 = mock.MagicMock()
net1.label = "private"
net2 = mock.MagicMock()
net2.label = "custom"
clients = mock.MagicMock()
clients.nova().networks.list.return_value = [net1, net2]
result = validator({}, clients, None)
self.assertTrue(result.is_valid, result.msg)
result = validator({"args": {"net": "custom"}}, clients, None)
self.assertTrue(result.is_valid, result.msg)
result = validator({"args": {"net": "custom2"}}, clients, None)
self.assertFalse(result.is_valid, result.msg)
# def test_network_exists(self):
# validator = self._unwrap_validator(validation.network_exists, "net")
#
# net1 = mock.MagicMock()
# net1.label = "private"
# net2 = mock.MagicMock()
# net2.label = "custom"
# clients = mock.MagicMock()
# clients.nova().networks.list.return_value = [net1, net2]
#
# result = validator({}, clients, None)
# self.assertTrue(result.is_valid, result.msg)
# result = validator({"args": {"net": "custom"}}, clients, None)
# self.assertTrue(result.is_valid, result.msg)
# result = validator({"args": {"net": "custom2"}}, clients, None)
# self.assertFalse(result.is_valid, result.msg)
def test_external_network_exists(self):
validator = self._unwrap_validator(