Commit f1ee1046 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

TemplateTool: upgrader first removes deprecated BT and then upgrade all BT

For example, if property_sheet "prop" was moved from BT 1 to BT 2 and BT 1 doesn't exist anymore.

Before this commit we have this order:
1 - install BT 2 ("prop" exist and isn't touched)
2 - remove BT 1 ("prop" is removed)
=> at the end "prop" doesn't exist anymore

After this commit we have this order:
1 - remove BT 1 ("prop" is removed)
2 - install BT 2 ("prop" is readded)
=> at the end "prop" exists and is OK
parent fddcc4d8
...@@ -1432,20 +1432,6 @@ class TemplateTool (BaseTool): ...@@ -1432,20 +1432,6 @@ class TemplateTool (BaseTool):
LOG('upgradeSite', 0, message) LOG('upgradeSite', 0, message)
dependency_list = [x[1] for x in \ dependency_list = [x[1] for x in \
self.resolveBusinessTemplateListDependency(bt5_list)] self.resolveBusinessTemplateListDependency(bt5_list)]
update_bt5_list = self.getRepositoryBusinessTemplateList(
template_list=dependency_list)
update_bt5_list.sort(key=lambda x: dependency_list.index(x.title))
for bt5 in update_bt5_list:
reinstall = bt5.title in deprecated_reinstall_set or bt5.force_install
if (not(reinstall) and bt5.version_state == 'present') or \
bt5.title in keep_bt5_id_set:
continue
append("Update %s business template in state %s%s" % \
(bt5.title, bt5.version_state, (reinstall and ' (reinstall)') or ''))
if not(dry_run):
bt5_url = "%s/%s" % (bt5.repository, bt5.title)
self.updateBusinessTemplateFromUrl(bt5_url, reinstall=reinstall,
update_catalog=update_catalog)
if delete_orphaned: if delete_orphaned:
if keep_bt5_id_set is None: if keep_bt5_id_set is None:
keep_bt5_id_set = set() keep_bt5_id_set = set()
...@@ -1463,6 +1449,20 @@ class TemplateTool (BaseTool): ...@@ -1463,6 +1449,20 @@ class TemplateTool (BaseTool):
if not(dry_run): if not(dry_run):
# XXX Here is missing parameters to really remove stuff # XXX Here is missing parameters to really remove stuff
bt.uninstall() bt.uninstall()
update_bt5_list = self.getRepositoryBusinessTemplateList(
template_list=dependency_list)
update_bt5_list.sort(key=lambda x: dependency_list.index(x.title))
for bt5 in update_bt5_list:
reinstall = bt5.title in deprecated_reinstall_set or bt5.force_install
if (not(reinstall) and bt5.version_state == 'present') or \
bt5.title in keep_bt5_id_set:
continue
append("Update %s business template in state %s%s" % \
(bt5.title, bt5.version_state, (reinstall and ' (reinstall)') or ''))
if not(dry_run):
bt5_url = "%s/%s" % (bt5.repository, bt5.title)
self.updateBusinessTemplateFromUrl(bt5_url, reinstall=reinstall,
update_catalog=update_catalog)
return message_list return message_list
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment