diff --git a/designate/objects/adapters/yaml/base.py b/designate/objects/adapters/yaml/base.py index 3585303bd..c65b95098 100644 --- a/designate/objects/adapters/yaml/base.py +++ b/designate/objects/adapters/yaml/base.py @@ -49,6 +49,10 @@ class YAMLAdapter(base.DesignateAdapter): # if not, move on new_obj = getattr(obj, key, None) obj_key = key + + if new_obj is None: + continue + # Check if this item is a relation (another DesignateObject that # will need to be converted itself if hasattr(obj.FIELDS.get(obj_key, {}), 'objname'): diff --git a/designate/tests/functional/manage/test_pool.py b/designate/tests/functional/manage/test_pool.py index b57fd2559..36c033f5d 100644 --- a/designate/tests/functional/manage/test_pool.py +++ b/designate/tests/functional/manage/test_pool.py @@ -68,6 +68,21 @@ class ManagePoolTestCase(designate.tests.functional.TestCase): 'Default PowerDNS 4 Pool', ''.join(self.command.output_message) ) + def test_show_config_catalog_zone(self): + self.command._setup() + self.command._create_pool(get_pools('pools-catalog-zone.yaml')[0]) + + pool_id = self.central_service.find_pool( + self.admin_context, {'name': 'default'}).id + + self.command.show_config(pool_id) + + self.print_result.assert_called_once() + self.assertIn('Pool Configuration', self.command.output_message[1]) + self.assertIn( + 'Default PowerDNS 4 Pool', ''.join(self.command.output_message) + ) + @mock.patch.object(service.Service, 'find_pool', side_effect=oslo_messaging.MessagingTimeout()) def test_show_config_rpc_timeout(self, mock_find_pool): diff --git a/designate/tests/resources/pools_yaml/pools-catalog-zone.yaml b/designate/tests/resources/pools_yaml/pools-catalog-zone.yaml new file mode 100644 index 000000000..b2533a647 --- /dev/null +++ b/designate/tests/resources/pools_yaml/pools-catalog-zone.yaml @@ -0,0 +1,36 @@ +--- + +- name: default + description: Default PowerDNS 4 Pool + + attributes: + type: internal + + ns_records: + - hostname: ns1-1.example.org. + priority: 1 + - hostname: ns1-2.example.org. + priority: 2 + + nameservers: + - host: 192.0.2.2 + port: 53 + - host: 192.0.2.3 + port: 53 + + targets: + - type: pdns4 + description: PowerDNS 4 Server + masters: + - host: 192.0.2.1 + port: 5354 + options: + api_endpoint: http://192.0.2.1:8081 + api_token: api_key + also_notifies: + - host: 192.0.2.4 + port: 53 + + catalog_zone: + catalog_zone_fqdn: example.org. + catalog_zone_refresh: '60' diff --git a/designate/tests/resources/pools_yaml/pools.yaml b/designate/tests/resources/pools_yaml/pools.yaml index b2533a647..6f05f4a53 100644 --- a/designate/tests/resources/pools_yaml/pools.yaml +++ b/designate/tests/resources/pools_yaml/pools.yaml @@ -30,7 +30,3 @@ also_notifies: - host: 192.0.2.4 port: 53 - - catalog_zone: - catalog_zone_fqdn: example.org. - catalog_zone_refresh: '60' diff --git a/releasenotes/notes/Fix-designate-manage-pool-update-with-missing-attributes-3037b2dad30f84e2.yaml b/releasenotes/notes/Fix-designate-manage-pool-update-with-missing-attributes-3037b2dad30f84e2.yaml new file mode 100644 index 000000000..d48f1eedf --- /dev/null +++ b/releasenotes/notes/Fix-designate-manage-pool-update-with-missing-attributes-3037b2dad30f84e2.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + So far, the yaml Adapter made every designate-manage pool command + fail if the pools.yaml file was missing any of the pool attributes. + This patch makes the adapter to continue without raising any error.