MCPcopy Index your code
hub / github.com/StackStorm/st2 / migrate_rules

Function migrate_rules

tools/migrate_rules_to_include_pack.py:121–142  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

119
120
121def 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
145def main():

Callers 1

mainFunction · 0.85

Calls 3

get_allMethod · 0.45
to_string_referenceMethod · 0.45
add_or_updateMethod · 0.45

Tested by

no test coverage detected