コード例 #1
0
 def test_resource_config_not_dict(self):
     nic_data = {'resources': {'foo': {'properties': {'config': None}}}}
     errors = validation.check_nic_configs("controller.yaml", nic_data)
     self.assertEqual(len(errors), 1)
     self.assertEqual(
         "The 'config' property of 'foo' must be"
         " a dictionary.", errors[0])
コード例 #2
0
 def test_more_than_one_bond(self):
     nic_data = self.nic_data([{
         'type': 'ovs_bridge',
         'name': 'storage',
         'members': [
             {
                 'type': 'ovs_bond',
                 'name': 'bond0',
                 'members': [
                     {'type': 'interface', 'name': 'eth0'},
                     {'type': 'interface', 'name': 'eth1'},
                 ]
             }, {
                 'type': 'ovs_bond',
                 'name': 'bond1',
                 'members': [
                     {'type': 'interface', 'name': 'eth2'},
                     {'type': 'interface', 'name': 'eth3'},
                 ]
             },
         ],
     }])
     errors = validation.check_nic_configs("controller.yaml", nic_data)
     self.assertEqual(len(errors), 1)
     self.assertIn('Invalid bonding: There are >= 2 bonds for bridge '
                   'storage', errors[0])
コード例 #3
0
 def test_one_bond_multiple_interfaces(self):
     nic_data = self.nic_data([{
         'type':
         'ovs_bridge',
         'name':
         'storage',
         'members': [
             {
                 'type':
                 'ovs_bond',
                 'name':
                 'bond0',
                 'members': [
                     {
                         'type': 'interface',
                         'name': 'eth2'
                     },
                     {
                         'type': 'interface',
                         'name': 'eth3'
                     },
                 ]
             },
             {
                 'type': 'interface',
                 'name': 'eth0'
             },
             {
                 'type': 'interface',
                 'name': 'eth1'
             },
         ],
     }])
     errors = validation.check_nic_configs("controller.yaml", nic_data)
     self.assertEqual([], errors)
コード例 #4
0
 def test_bridge_has_name(self):
     nic_data = self.nic_data([{
         'type': 'ovs_bridge',
         'members': [],
     }])
     errors = validation.check_nic_configs("controller.yaml", nic_data)
     self.assertEqual(len(errors), 1)
     self.assertIn("'name' is a required property", errors[0])
コード例 #5
0
 def test_ovs_bridge_has_members(self):
     nic_data = self.nic_data([{
         'name': 'storage',
         'type': 'ovs_bridge',
         'members': None,
     }])
     errors = validation.check_nic_configs("controller.yaml", nic_data)
     self.assertEqual(len(errors), 1)
     self.assertIn("members/type: 'None' is not of type 'array'", errors[0])
コード例 #6
0
 def test_one_interface_without_bond(self):
     nic_data = self.nic_data([{
         'type': 'ovs_bridge',
         'name': 'storage',
         'members': [
             {'type': 'interface', 'name': 'eth0'},
         ],
     }])
     errors = validation.check_nic_configs("controller.yaml", nic_data)
     self.assertEqual([], errors)
コード例 #7
0
 def test_ovs_bridge_members_dict(self):
     nic_data = self.nic_data([{
         'name': 'storage',
         'type': 'ovs_bridge',
         'members': [None],
     }])
     errors = validation.check_nic_configs("controller.yaml", nic_data)
     self.assertEqual(len(errors), 1)
     self.assertIn(
         "members/items/oneOf: None is not valid under any"
         " of the given schemas", errors[0])
コード例 #8
0
 def test_bridge_has_only_known_properties(self):
     nic_data = self.nic_data([{
         'type': 'ovs_bridge',
         'name': 'storage',
         'member': [],
     }])
     errors = validation.check_nic_configs("controller.yaml", nic_data)
     self.assertEqual(len(errors), 1)
     self.assertIn(
         "Additional properties are not allowed"
         " ('member' was unexpected)", errors[0])
コード例 #9
0
 def test_bonds_have_known_type(self):
     nic_data = self.nic_data([{
         'type': 'magic_bridge',
         'name': 'storage',
         'members': [{}],
     }])
     errors = validation.check_nic_configs("controller.yaml", nic_data)
     self.assertEqual(len(errors), 1)
     self.assertIn(
         "members/items/oneOf: {} is not valid under any"
         " of the given schemas", errors[0])
コード例 #10
0
 def test_multiple_interfaces_without_bond(self):
     nic_data = self.nic_data([{
         'type': 'ovs_bridge',
         'name': 'storage',
         'members': [
             {'type': 'interface', 'name': 'eth0'},
             {'type': 'interface', 'name': 'eth1'},
         ],
     }])
     errors = validation.check_nic_configs("controller.yaml", nic_data)
     self.assertEqual(len(errors), 1)
     self.assertIn('Invalid interface: When not using a bond, there can'
                   ' only be 1 interface for bridge storage', errors[0])
コード例 #11
0
 def test_one_interface_without_bond(self):
     nic_data = self.nic_data([{
         'type':
         'ovs_bridge',
         'name':
         'storage',
         'members': [
             {
                 'type': 'interface',
                 'name': 'eth0'
             },
         ],
     }])
     errors = validation.check_nic_configs("controller.yaml", nic_data)
     self.assertEqual([], errors)
コード例 #12
0
 def test_one_bond_no_interfaces(self):
     nic_data = self.nic_data([{
         'type':
         'ovs_bridge',
         'name':
         'storage',
         'members': [
             {
                 'type': 'ovs_bond',
                 'name': 'bond0',
                 'members': []
             },
         ],
     }])
     errors = validation.check_nic_configs("controller.yaml", nic_data)
     self.assertEqual(len(errors), 1)
     self.assertIn('members/minItems: [] is too short', errors[0])
コード例 #13
0
 def test_more_than_one_bond(self):
     nic_data = self.nic_data([{
         'type':
         'ovs_bridge',
         'name':
         'storage',
         'members': [
             {
                 'type':
                 'ovs_bond',
                 'name':
                 'bond0',
                 'members': [
                     {
                         'type': 'interface',
                         'name': 'eth0'
                     },
                     {
                         'type': 'interface',
                         'name': 'eth1'
                     },
                 ]
             },
             {
                 'type':
                 'ovs_bond',
                 'name':
                 'bond1',
                 'members': [
                     {
                         'type': 'interface',
                         'name': 'eth2'
                     },
                     {
                         'type': 'interface',
                         'name': 'eth3'
                     },
                 ]
             },
         ],
     }])
     errors = validation.check_nic_configs("controller.yaml", nic_data)
     self.assertEqual(len(errors), 1)
     self.assertIn(
         'Invalid bonding: There are >= 2 bonds for bridge '
         'storage', errors[0])
コード例 #14
0
 def test_one_bond_multiple_interfaces(self):
     nic_data = self.nic_data([{
         'type': 'ovs_bridge',
         'name': 'storage',
         'members': [
             {
                 'type': 'ovs_bond',
                 'name': 'bond0',
                 'members': [
                     {'type': 'interface', 'name': 'eth2'},
                     {'type': 'interface', 'name': 'eth3'},
                 ]
             },
             {'type': 'interface', 'name': 'eth0'},
             {'type': 'interface', 'name': 'eth1'},
         ],
     }])
     errors = validation.check_nic_configs("controller.yaml", nic_data)
     self.assertEqual([], errors)
コード例 #15
0
 def test_multiple_interfaces_without_bond(self):
     nic_data = self.nic_data([{
         'type':
         'ovs_bridge',
         'name':
         'storage',
         'members': [
             {
                 'type': 'interface',
                 'name': 'eth0'
             },
             {
                 'type': 'interface',
                 'name': 'eth1'
             },
         ],
     }])
     errors = validation.check_nic_configs("controller.yaml", nic_data)
     self.assertEqual(len(errors), 1)
     self.assertIn(
         'Invalid interface: When not using a bond, there can'
         ' only be 1 interface for bridge storage', errors[0])
コード例 #16
0
 def test_non_dict(self):
     errors = validation.check_nic_configs("controller.yaml", None)
     self.assertEqual(len(errors), 1)
     self.assertEqual('The nic_data parameter must be a dictionary.',
                      errors[0])
コード例 #17
0
 def _test_resources_invalid(self, nic_data):
     errors = validation.check_nic_configs("controller.yaml", nic_data)
     self.assertEqual(len(errors), 1)
     self.assertEqual(
         "The nic_data must contain the 'resources' key and it"
         " must be a dictionary.", errors[0])
コード例 #18
0
 def test_network_config_not_list(self):
     nic_data = self.nic_data(None)
     errors = validation.check_nic_configs("controller.yaml", nic_data)
     self.assertEqual(len(errors), 1)
     self.assertIn("'foo' must be a list", errors[0])
コード例 #19
0
 def test_resource_config_not_dict(self):
     nic_data = {'resources': {'foo': {'properties': {'config': None}}}}
     errors = validation.check_nic_configs("controller.yaml", nic_data)
     self.assertEqual(len(errors), 1)
     self.assertEqual("The 'config' property of 'foo' must be"
                      " a dictionary.", errors[0])
コード例 #20
0
 def test_non_dict(self):
     errors = validation.check_nic_configs("controller.yaml", None)
     self.assertEqual(len(errors), 1)
     self.assertEqual('The nic_data parameter must be a dictionary.',
                      errors[0])
コード例 #21
0
 def _test_resources_invalid(self, nic_data):
     errors = validation.check_nic_configs("controller.yaml", nic_data)
     self.assertEqual(len(errors), 1)
     self.assertEqual("The nic_data must contain the 'resources' key and it"
                      " must be a dictionary.", errors[0])
コード例 #22
0
 def test_bridge_is_of_known_type(self):
     nic_data = self.nic_data([{'type': 'intreface'}])
     errors = validation.check_nic_configs("controller.yaml", nic_data)
     self.assertEqual(len(errors), 1)
     self.assertIn("{'type': 'intreface'} is not valid", errors[0])
コード例 #23
0
 def test_resource_not_dict(self):
     nic_data = {'resources': {'foo': None}}
     errors = validation.check_nic_configs("controller.yaml", nic_data)
     self.assertEqual(len(errors), 1)
     self.assertEqual("'foo' is not a valid resource.", errors[0])
コード例 #24
0
 def test_resource_not_dict(self):
     nic_data = {'resources': {'foo': None}}
     errors = validation.check_nic_configs("controller.yaml", nic_data)
     self.assertEqual(len(errors), 1)
     self.assertEqual("'foo' is not a valid resource.", errors[0])
コード例 #25
0
 def test_network_config_not_list(self):
     nic_data = self.nic_data(None)
     errors = validation.check_nic_configs("controller.yaml", nic_data)
     self.assertEqual(len(errors), 1)
     self.assertIn("'foo' must be a list", errors[0])