()
| 119 | |
| 120 | |
| 121 | def migrate_rules(): |
| 122 | try: |
| 123 | existing_rules = RuleWithoutPack.get_all() |
| 124 | |
| 125 | for rule in existing_rules: |
| 126 | rule_with_pack = Migration.RuleDB( |
| 127 | id=rule.id, |
| 128 | name=rule.name, |
| 129 | description=rule.description, |
| 130 | trigger=rule.trigger, |
| 131 | criteria=rule.criteria, |
| 132 | action=rule.action, |
| 133 | enabled=rule.enabled, |
| 134 | pack=DEFAULT_PACK_NAME, |
| 135 | ref=ResourceReference.to_string_reference( |
| 136 | pack=DEFAULT_PACK_NAME, name=rule.name |
| 137 | ), |
| 138 | ) |
| 139 | print("Migrating rule: %s to rule: %s" % (rule.name, rule_with_pack.ref)) |
| 140 | RuleWithPack.add_or_update(rule_with_pack) |
| 141 | except Exception as e: |
| 142 | print("Migration failed. %s" % six.text_type(e)) |
| 143 | |
| 144 | |
| 145 | def main(): |
no test coverage detected