Fix property TTL in Designate::Domain
Current property ttl of Domain is incorrect:
1. Minimum of ttl is 1, not 0;
2. If ttl is None, it should not be in create method args.
Change-Id: I632c13f879bd42cf829bc3b490850e78f371ff0f
Closes-bug: #1523538
(cherry picked from commit ef224da971
)
This commit is contained in:
parent
0441ca8fed
commit
8d788da2e1
@ -10,6 +10,7 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import six
|
||||
|
||||
from heat.common.i18n import _
|
||||
from heat.engine import attributes
|
||||
@ -47,12 +48,12 @@ class DesignateDomain(resource.Resource):
|
||||
required=True,
|
||||
constraints=[constraints.Length(max=255)]
|
||||
),
|
||||
# Based on RFC 1035, range for ttl is set to 0 to signed 32 bit number
|
||||
# Based on RFC 1035, range for ttl is set to 1 to signed 32 bit number
|
||||
TTL: properties.Schema(
|
||||
properties.Schema.INTEGER,
|
||||
_('Time To Live (Seconds).'),
|
||||
update_allowed=True,
|
||||
constraints=[constraints.Range(min=0,
|
||||
constraints=[constraints.Range(min=1,
|
||||
max=2147483647)]
|
||||
),
|
||||
# designate mandates to the max length of 160 for description
|
||||
@ -82,13 +83,7 @@ class DesignateDomain(resource.Resource):
|
||||
entity = 'domains'
|
||||
|
||||
def handle_create(self):
|
||||
args = dict(
|
||||
name=self.properties[self.NAME],
|
||||
email=self.properties[self.EMAIL],
|
||||
description=self.properties[self.DESCRIPTION],
|
||||
ttl=self.properties[self.TTL]
|
||||
)
|
||||
|
||||
args = dict((k, v) for k, v in six.iteritems(self.properties) if v)
|
||||
domain = self.client_plugin().domain_create(**args)
|
||||
|
||||
self.resource_id_set(domain.id)
|
||||
|
@ -180,3 +180,15 @@ class DesignateDomainTest(common.HeatTestCase):
|
||||
self.assertEqual(args,
|
||||
self.test_resource._show_resource(),
|
||||
'Failed to show resource')
|
||||
|
||||
def test_no_ttl(self):
|
||||
mock_domain_create = self.test_client_plugin.domain_create
|
||||
mock_resource = self._get_mock_resource()
|
||||
mock_domain_create.return_value = mock_resource
|
||||
|
||||
self.test_resource.properties.data['ttl'] = None
|
||||
|
||||
self.test_resource.handle_create()
|
||||
mock_domain_create.assert_called_once_with(
|
||||
name='test-domain.com', description='Test domain',
|
||||
email='abc@test-domain.com')
|
||||
|
Loading…
Reference in New Issue
Block a user