diff options
author | Stuart Mackie <wsmackie@juniper.net> | 2017-03-23 06:19:54 -0700 |
---|---|---|
committer | Stuart Mackie <wsmackie@juniper.net> | 2017-03-23 06:19:54 -0700 |
commit | 88df88a19674ccc0017836941b8ee32eaadf19fb (patch) | |
tree | f930c90f75846ec8d8e33cf27325ff8fafc85d5c /charms/trusty/kafka/hooks/common.py | |
parent | 9f50a40437477432a21b326b15c343ca6b8fe516 (diff) |
Deleted charms with wrong license. Will source them differently in future.
Change-Id: I0fc99ea03c6b6ca4701e63793cb2be60e56c7588
Signed-off-by: Stuart Mackie <wsmackie@juniper.net>
Diffstat (limited to 'charms/trusty/kafka/hooks/common.py')
-rwxr-xr-x | charms/trusty/kafka/hooks/common.py | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/charms/trusty/kafka/hooks/common.py b/charms/trusty/kafka/hooks/common.py deleted file mode 100755 index 1ca080b..0000000 --- a/charms/trusty/kafka/hooks/common.py +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/env python -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -""" -Common implementation for all hooks. -""" - -import jujuresources -from charmhelpers.core import hookenv -from charmhelpers.core import unitdata -from charmhelpers.core import charmframework - - -def bootstrap_resources(): - """ - Install required resources defined in resources.yaml - """ - if unitdata.kv().get('charm.bootstrapped', False): - return True - hookenv.status_set('maintenance', 'Installing base resources') - mirror_url = jujuresources.config_get('resources_mirror') - if not jujuresources.fetch(mirror_url=mirror_url): - missing = jujuresources.invalid() - hookenv.status_set('blocked', 'Unable to fetch required resource%s: %s' % ( - 's' if len(missing) > 1 else '', - ', '.join(missing), - )) - return False - jujuresources.install(['pathlib', 'jujubigdata']) - unitdata.kv().set('charm.bootstrapped', True) - return True - - -def manage(): - if not bootstrap_resources(): - # defer until resources are available, since charmhelpers, and thus - # the framework, are required (will require manual intervention) - return - - import jujubigdata - import callbacks - - kafka_reqs = ['vendor', 'packages', 'groups', 'users', 'dirs', 'ports'] - dist_config = jujubigdata.utils.DistConfig(filename='dist.yaml', - required_keys=kafka_reqs) - kafka = callbacks.Kafka(dist_config) - manager = charmframework.Manager([ - { - 'name': 'kafka', - 'provides': [ - jujubigdata.relations.Kafka(port=dist_config.port('kafka')) - ], - 'requires': [ - kafka.verify_resources, - jujubigdata.relations.Zookeeper(), - callbacks.update_blocked_status, # not really a requirement, but best way to fit into framework - ], - 'callbacks': [ - callbacks.update_working_status, - kafka.install, - kafka.configure_kafka, - kafka.restart, - charmframework.helpers.open_ports( - dist_config.exposed_ports('kafka')), - callbacks.update_active_status, - ], - 'cleanup': [ - callbacks.clear_active_flag, - charmframework.helpers.close_ports( - dist_config.exposed_ports('kafka')), - kafka.stop, - kafka.cleanup, - callbacks.update_blocked_status, - ], - }, - ]) - manager.manage() - - -if __name__ == '__main__': - manage() |