deb-sahara/sahara/plugins/mapr/util/event_log.py
Artem Osadchyi 45009845e8 Add event logs for MapR plugin
MapR plugin now supports event logs. To complete
this task several additional changes were made:
1. Move node awareness checking from within configure_topology method
2. Add instances parameter to set_cluster_mode
3. Move topology map generation to cluster context
4. Move configs resolving to cluster context

Change-Id: Ic00b27f57eacf5664980358b7fd154632ef3f31e
Implements: blueprint mapr-event-log
2015-10-12 18:13:43 +03:00

60 lines
1.9 KiB
Python

# Copyright (c) 2015, MapR Technologies
#
# 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.
from sahara.utils import cluster_progress_ops as cpo
def provision_step(name, cluster_context_reference=1, instances_reference=2):
def wrapper(function):
def wrapped(*args, **kwargs):
cluster_context = _find_argument(
cluster_context_reference, *args, **kwargs)
instances = _find_argument(instances_reference, *args, **kwargs)
cluster_id = cluster_context.cluster.id
instance_count = len(instances)
cpo.add_provisioning_step(cluster_id, name, instance_count)
return function(*args, **kwargs)
return wrapped
return wrapper
def provision_event(instance_reference=0):
def wrapper(function):
def wrapped(*args, **kwargs):
instance = _find_argument(instance_reference, *args, **kwargs)
try:
result = function(*args, **kwargs)
cpo.add_successful_event(instance)
return result
except Exception as exception:
cpo.add_fail_event(instance, exception)
raise exception
return wrapped
return wrapper
def _find_argument(reference, *args, **kwargs):
if isinstance(reference, int):
return args[reference]
if isinstance(reference, str):
return kwargs[reference]