Bug #12980
opencannot rename organization
Description
Renaming a organization takes a huge amount of time and fails eventually.
a = Organization.find('FD-PS-LX')
a.name = 'FD-ITS-LX'
a.save!
Stuff that takes forever:
ProvisioningTemplate Load (0.6ms) SELECT `templates`.* FROM `templates` INNER JOIN `operatingsystems_provisioning_templates` ON `operatingsystems_provisioning_templates`.`provisioning_template_id` = `templates`.`id` INNER JOIN `operatingsystems` ON `operatingsystems`.`id` = `operatingsystems_provisioning_templates`.`operatingsystem_id` INNER JOIN `template_kinds` ON `template_kinds`.`id` = `templates`.`template_kind_id` INNER JOIN `template_combinations` ON `template_combinations`.`provisioning_template_id` = `templates`.`id` WHERE `templates`.`type` IN ('ProvisioningTemplate') AND `operatingsystems`.`id` = 24 AND `template_kinds`.`name` = 'provision' AND `template_combinations`.`hostgroup_id` = 267 AND `template_combinations`.`environment_id` IS NULL ORDER BY templates.name LIMIT 1
ProvisioningTemplate Load (0.7ms) SELECT `templates`.* FROM `templates` INNER JOIN `operatingsystems_provisioning_templates` ON `operatingsystems_provisioning_templates`.`provisioning_template_id` = `templates`.`id` INNER JOIN `operatingsystems` ON `operatingsystems`.`id` = `operatingsystems_provisioning_templates`.`operatingsystem_id` INNER JOIN `template_kinds` ON `template_kinds`.`id` = `templates`.`template_kind_id` INNER JOIN `template_combinations` ON `template_combinations`.`provisioning_template_id` = `templates`.`id` WHERE `templates`.`type` IN ('ProvisioningTemplate') AND `operatingsystems`.`id` = 24 AND `template_kinds`.`name` = 'provision' AND `template_combinations`.`hostgroup_id` IS NULL AND `template_combinations`.`environment_id` = 179 ORDER BY templates.name LIMIT 1
Failure:
(0.5ms) ROLLBACK
ActiveRecord::RecordInvalid: Validation failed: Hostgroups you cannot remove hostgroups that are used by hosts or inherited., Provisioning templates you cannot remove provisioning templates that are used by hosts or inherited.