コード例 #1
0
    def post(self, name, source='custom', target_resource=None, data=None):
        LOG.debug('POST plugin ' + name + ':' + source + ':')
        manager = get_plugin_handler()
        try:
            plugin = manager.check_plugin_name(name)
            conversor = data_convert.FormatterBase.get_formatter(source)

        except exceptions.InvalidSourceException as e:
            LOG.exception(e)
            abort(500, e.message)
        except Exception as e:
            #add conversor not found, pluginnotfound exception
            LOG.exception(e)
            abort(404, e.message)
        #if ceilometer, fetch header data and resource
        #if custom, just expose data
        #source converter(source, extra_data, headers)

        #TODO: normalize data in object?
        action_data = conversor.format(name,
                                       data,
                                       target_resource=target_resource,
                                       headers=pecan.request.headers)
        action_data.create()
        LOG.debug(action_data)
        #TODO: Retrieve context if token in header from middleware
        #Should be done on authorization? If not provided used admin
        #build context should not call authorize in that case
        ctx = utils.build_context(None, True)
        self.action_rpc.run_action(ctx, [action_data])
        return {'action_id': action_data.id}
コード例 #2
0
ファイル: handler.py プロジェクト: lcostantino/healing-os
    def post(self, name, source='custom', target_resource=None, data=None):
        LOG.debug('POST plugin ' + name + ':' + source + ':')
        manager = get_plugin_handler()
        try:
            plugin = manager.check_plugin_name(name)
            conversor = data_convert.FormatterBase.get_formatter(source)

        except exceptions.InvalidSourceException as e:
            LOG.exception(e)
            abort(500, e.message)
        except Exception as e:
            #add conversor not found, pluginnotfound exception
            LOG.exception(e)
            abort(404, e.message)
        #if ceilometer, fetch header data and resource
        #if custom, just expose data
        #source converter(source, extra_data, headers)

        #TODO: normalize data in object?
        action_data = conversor.format(name, data,
                                       target_resource=target_resource,
                                       headers=pecan.request.headers)
        action_data.create()
        LOG.debug(action_data)
        #TODO: Retrieve context if token in header from middleware
        #Should be done on authorization? If not provided used admin
        #build context should not call authorize in that case
        ctx = utils.build_context(None, True)
        self.action_rpc.run_action(ctx, [action_data])
        return {'action_id': action_data.id}
コード例 #3
0
 def periodic_tasks(self, raise_on_error=False):
     """Tasks to be run at a periodic interval."""
     # ctxt has not adquired token yet...
     print "PERIODIC: "
     print "================="
     ctxt = utils.build_context(admin=True, authorize=False)
     return self.manager.periodic_tasks(ctxt, raise_on_error=raise_on_error)
コード例 #4
0
 def run_action(self, context, actions, block=False):
     if not type(actions) == list:
         actions = [actions]
     #if not context:
     #    context = utils.build_context()
     # remove, is for test
     context = utils.build_context()
     return handler_manager().start_plugins_group(context,
                                                  actions,
                                                  block=block)
コード例 #5
0
    def before(self, state):
        if not config.CONF.pecan.auth_enable:
            state.request.admin_ctx = utils.build_context()
            return
        if self._should_authorize_url(state.request.url) and \
            not is_valid_admin_user(state.request.headers):
            # (TODO) add log
            raise exceptions.AuthorizationException('Required admin')

        state.request.admin_ctx = utils.context_from_headers(
                                                        state.request.headers)
コード例 #6
0
 def alarm(self,
           ctxt,
           alarm_id,
           source=None,
           contract_id=None,
           resource_id=None,
           project_id=None):
     # TODO: check why token is not there, from notification my be ok , but
     # from API is still the same?
     if ctxt.token is None:
         ctxt = utils.build_context()
     self.engine.alert(ctxt,
                       alarm_id,
                       source,
                       contract_id=contract_id,
                       resource_id=resource_id,
                       project_id=project_id)
コード例 #7
0
 def post(self, contract):
     ctx = utils.build_context(None, True)
     contract_dict = self.engine.create(ctx, contract.to_dict())
     return SLAContract.from_dict(contract_dict)
コード例 #8
0
 def delete(self, id):
     ctx = utils.build_context(None, True)
     self.engine.delete(ctx, id)
コード例 #9
0
 def put(self, contract_id, contract):
     ctx = utils.build_context(None, True)
     contract.id = contract_id
     contract_dict = self.engine.update(ctx, contract.to_dict())
     return SLAContract.from_dict(contract_dict)
コード例 #10
0
from healing import config
from healing import utils
from healing import handler_manager
from healing.handler_plugins import action_data
from healing.engine.alarms import manager
from healing.engine.alarms import filters

from healing.openstack.common import log as logging

logging.setup('heal')

config.parse_args()
ctx = utils.build_context()

mg = handler_manager.get_plugin_handler()

to_run = []
for x in range(1, 20):
    to_run.append(
        action_data.ActionData(name='evacuate', target_resource='s', data={}))

print mg.start_plugins_group(ctx, to_run)
"""
#nv = utils.get_nova_client(ctx)

#print utils.get_nova_vms(nv)
#print utils.get_nova_vms(nv, tenant_id=22222)
#print utils.get_nova_vms(nv, host='ubuntu-SVT13125CLS')


コード例 #11
0
from healing import config
from healing import utils
from healing import handler_manager
from healing.handler_plugins import action_data
from healing.engine.alarms import manager
from healing.engine.alarms import filters

from healing.openstack.common import log as logging

logging.setup('heal')

config.parse_args()
ctx = utils.build_context()

mg = handler_manager.get_plugin_handler()

to_run = []
for x in range(1,20):
    to_run.append(action_data.ActionData(name='evacuate', target_resource='s', data={}))
    

           
print mg.start_plugins_group(ctx, to_run)
"""
#nv = utils.get_nova_client(ctx)

#print utils.get_nova_vms(nv)
#print utils.get_nova_vms(nv, tenant_id=22222)
#print utils.get_nova_vms(nv, host='ubuntu-SVT13125CLS')

コード例 #12
0
ファイル: sla.py プロジェクト: lcostantino/healing-os
 def post(self, contract):
     ctx = utils.build_context(None, True)
     contract_dict = self.engine.create(ctx, contract.to_dict())
     return SLAContract.from_dict(contract_dict)
コード例 #13
0
ファイル: sla.py プロジェクト: lcostantino/healing-os
 def delete(self, id):
     ctx = utils.build_context(None, True)
     self.engine.delete(ctx, id)
コード例 #14
0
ファイル: sla.py プロジェクト: lcostantino/healing-os
 def put(self, contract_id, contract):
     ctx = utils.build_context(None, True)
     contract.id = contract_id
     contract_dict = self.engine.update(ctx, contract.to_dict())
     return SLAContract.from_dict(contract_dict)