diff options
-rw-r--r-- | ironic/db/api.py | 3 | ||||
-rw-r--r-- | ironic/db/sqlalchemy/api.py | 12 | ||||
-rw-r--r-- | ironic/objects/deploy_template.py | 3 | ||||
-rw-r--r-- | ironic/tests/unit/db/test_deploy_templates.py | 5 | ||||
-rw-r--r-- | ironic/tests/unit/db/utils.py | 5 | ||||
-rw-r--r-- | ironic/tests/unit/objects/test_deploy_template.py | 1 |
6 files changed, 12 insertions, 17 deletions
diff --git a/ironic/db/api.py b/ironic/db/api.py index 135b762e4..0ae9bf00d 100644 --- a/ironic/db/api.py +++ b/ironic/db/api.py @@ -1167,7 +1167,7 @@ class Connection(object): """ @abc.abstractmethod - def create_deploy_template(self, values, version): + def create_deploy_template(self, values): """Create a deployment template. :param values: A dict describing the deployment template. For example: @@ -1178,7 +1178,6 @@ class Connection(object): 'uuid': uuidutils.generate_uuid(), 'name': 'CUSTOM_DT1', } - :param version: the version of the object.DeployTemplate. :raises: DeployTemplateDuplicateName if a deploy template with the same name exists. :raises: DeployTemplateAlreadyExists if a deploy template with the same diff --git a/ironic/db/sqlalchemy/api.py b/ironic/db/sqlalchemy/api.py index 468d01c93..3b50423c6 100644 --- a/ironic/db/sqlalchemy/api.py +++ b/ironic/db/sqlalchemy/api.py @@ -1786,7 +1786,7 @@ class Connection(api.Connection): return results @oslo_db_api.retry_on_deadlock - def create_deploy_template(self, values, version): + def create_deploy_template(self, values): steps = values.get('steps', []) values['steps'] = self._get_deploy_template_steps(steps) @@ -1817,9 +1817,8 @@ class Connection(api.Connection): return step.interface, step.step, step.args, step.priority # List all existing steps for the template. - query = (model_query(models.DeployTemplateStep) - .filter_by(deploy_template_id=template_id)) - current_steps = query.all() + current_steps = (model_query(models.DeployTemplateStep) + .filter_by(deploy_template_id=template_id)) # List the new steps for the template. new_steps = self._get_deploy_template_steps(steps, template_id) @@ -1867,10 +1866,7 @@ class Connection(api.Connection): template=template_id) # First, update non-step columns. - steps = None - if 'steps' in values: - steps = values.pop('steps') - + steps = values.pop('steps', None) ref.update(values) # If necessary, update steps. diff --git a/ironic/objects/deploy_template.py b/ironic/objects/deploy_template.py index f6358fae5..2be2eb7f9 100644 --- a/ironic/objects/deploy_template.py +++ b/ironic/objects/deploy_template.py @@ -51,8 +51,7 @@ class DeployTemplate(base.IronicObject, object_base.VersionedObjectDictCompat): UUID exists. """ values = self.do_version_changes_for_db() - db_template = self.dbapi.create_deploy_template( - values, values['version']) + db_template = self.dbapi.create_deploy_template(values) self._from_db_object(self._context, self, db_template) # NOTE(mgoddard): We don't want to enable RPC on this call just yet. diff --git a/ironic/tests/unit/db/test_deploy_templates.py b/ironic/tests/unit/db/test_deploy_templates.py index 59fdb447a..8e17af805 100644 --- a/ironic/tests/unit/db/test_deploy_templates.py +++ b/ironic/tests/unit/db/test_deploy_templates.py @@ -61,7 +61,7 @@ class DbDeployTemplateTestCase(base.DbTestCase): del template['steps'][0]['interface'] self.assertRaises(db_exc.DBError, self.dbapi.create_deploy_template, - template, None) + template) def test_update_name(self): values = {'name': 'CUSTOM_DT2'} @@ -147,8 +147,9 @@ class DbDeployTemplateTestCase(base.DbTestCase): def test_get_deploy_template_by_uuid(self): res = self.dbapi.get_deploy_template_by_uuid(self.template.uuid) self.assertEqual(self.template.id, res.id) + invalid_uuid = uuidutils.generate_uuid() self.assertRaises(exception.DeployTemplateNotFound, - self.dbapi.get_deploy_template_by_uuid, -1) + self.dbapi.get_deploy_template_by_uuid, invalid_uuid) def test_get_deploy_template_by_name(self): res = self.dbapi.get_deploy_template_by_name(self.template.name) diff --git a/ironic/tests/unit/db/utils.py b/ironic/tests/unit/db/utils.py index 7b6be120a..6e91643a2 100644 --- a/ironic/tests/unit/db/utils.py +++ b/ironic/tests/unit/db/utils.py @@ -624,13 +624,14 @@ def create_test_allocation(**kw): def get_test_deploy_template(**kw): + default_uuid = uuidutils.generate_uuid() return { 'version': kw.get('version', deploy_template.DeployTemplate.VERSION), 'created_at': kw.get('created_at'), 'updated_at': kw.get('updated_at'), 'id': kw.get('id', 234), 'name': kw.get('name', u'CUSTOM_DT1'), - 'uuid': kw.get('uuid', 'aa75a317-2929-47d4-b676-fd9bff578bf1'), + 'uuid': kw.get('uuid', default_uuid), 'steps': kw.get('steps', [get_test_deploy_template_step( deploy_template_id=kw.get('id', 234))]), } @@ -668,4 +669,4 @@ def create_test_deploy_template(**kw): for kw_step, template_step in zip(kw['steps'], template['steps']): if 'id' not in kw_step: del template_step['id'] - return dbapi.create_deploy_template(template, template['version']) + return dbapi.create_deploy_template(template) diff --git a/ironic/tests/unit/objects/test_deploy_template.py b/ironic/tests/unit/objects/test_deploy_template.py index e32c30f20..055c9e2b7 100644 --- a/ironic/tests/unit/objects/test_deploy_template.py +++ b/ironic/tests/unit/objects/test_deploy_template.py @@ -37,7 +37,6 @@ class TestDeployTemplateObject(db_base.DbTestCase, obj_utils.SchemasTestMixIn): template.create() args, _kwargs = mock_create.call_args - self.assertEqual(objects.DeployTemplate.VERSION, args[0]['version']) self.assertEqual(1, mock_create.call_count) self.assertEqual(self.fake_template['name'], template.name) |