| Adam Israel | 102cd7f | 2018-05-08 12:55:29 -0400 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | ## |
| 3 | # Copyright 2016 Canonical Ltd. |
| 4 | # All rights reserved. |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 7 | # not use this file except in compliance with the License. You may obtain |
| 8 | # a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 15 | # License for the specific language governing permissions and limitations |
| 16 | # under the License. |
| 17 | ## |
| 18 | import sys |
| 19 | sys.path.append('lib') |
| 20 | |
| Adam Israel | 7a5344c | 2018-06-21 15:57:00 -0400 | [diff] [blame] | 21 | from charms.reactive import main, set_flag |
| Adam Israel | 102cd7f | 2018-05-08 12:55:29 -0400 | [diff] [blame] | 22 | from charmhelpers.core.hookenv import action_fail, action_name |
| 23 | |
| 24 | """ |
| 25 | `set_state` only works here because it's flushed to disk inside the `main()` |
| 26 | loop. remove_state will need to be called inside the action method. |
| 27 | """ |
| Adam Israel | 7a5344c | 2018-06-21 15:57:00 -0400 | [diff] [blame] | 28 | set_flag('actions.{}'.format(action_name())) |
| Adam Israel | 102cd7f | 2018-05-08 12:55:29 -0400 | [diff] [blame] | 29 | |
| 30 | try: |
| 31 | main() |
| 32 | except Exception as e: |
| 33 | action_fail(repr(e)) |