def main(): aim_cfg.init(sys.argv[1:]) aim_cfg.setup_logging() signal.signal(signal.SIGTERM, shutdown) try: run(aim_cfg.CONF, False) except (RuntimeError, ValueError) as e: LOG.error("%s CherryPy Server terminated!" % e) sys.exit(1)
def main(klass): aim_cfg.init(sys.argv[1:]) aim_cfg.setup_logging() try: agent = klass(aim_cfg.CONF) except (RuntimeError, ValueError) as e: LOG.error("%s Agent terminated!" % e) sys.exit(1) signal.signal(signal.SIGTERM, agent._handle_sigterm) agent.run()
class aimCrud(object): global aim_ctx, mgr aim_config.init(['--config-file', '/etc/aim/aim.conf']) session = db_api.get_session(expire_on_commit=True) aim_ctx = aim_context.AimContext(db_session=session) mgr = aim_manager.AimManager() def update_contract_subject(self, cont_subj, **kwargs): return "TBD"
if 'Svc' in cs.name: csfltrs = cs.__dict__['bi_filters'] if action == 'create': #add filter to svc-ctc-subj csfltrs.append('noiro-ssh') mgr.update(aim_ctx, cs, bi_filters=csfltrs) if action == 'delete': #del filter to svc-ctc-subj csfltrs.remove('noiro-ssh') mgr.update(aim_ctx, cs, bi_filters=csfltrs) except Exception as e: print '\nUpdate of svc-ctc failed: ' + repr(e) return 0 ## Get Global instances/variables action = sys.argv[1] aim_config.init(['--config-file', '/etc/aim/aim.conf']) session = db_api.get_session(expire_on_commit=True) aim_ctx = aim_context.AimContext(db_session=session) mgr = aim_manager.AimManager() ## Instantiate crud class crud = aimcrud() if action == 'create': # Create a filter print "\nCreating the Filter noiro-ssh" crud.act_filter(action) # Create filter-entries print "\nCreating Filter-entries ssh & rev-ssh" crud.act_filter_entry(action) # Add the noiro-ssh filter to Svc Contract Subject print "\nAdding the noiro-ssh filter to Svc Contract Subject"
for cs in mgr.find(aim_ctx,resource.ContractSubject): if 'Svc' in cs.name: csfltrs = cs.__dict__['bi_filters'] if action == 'create': #add filter to svc-ctc-subj csfltrs.append('noiro-ssh') mgr.update(aim_ctx,cs,bi_filters=csfltrs) if action == 'delete': #del filter to svc-ctc-subj csfltrs.remove('noiro-ssh') mgr.update(aim_ctx,cs,bi_filters=csfltrs) except Exception as e: print '\nUpdate of svc-ctc failed: '+repr(e) return 0 ## Get Global instances/variables action = sys.argv[1] aim_config.init(['--config-file', '/etc/aim/aim.conf']) session = db_api.get_session(expire_on_commit=True) aim_ctx = aim_context.AimContext(db_session=session) mgr = aim_manager.AimManager() ## Instantiate crud class crud = aimcrud() if action == 'create': # Create a filter print "\nCreating the Filter noiro-ssh" crud.act_filter(action) # Create filter-entries print "\nCreating Filter-entries ssh & rev-ssh" crud.act_filter_entry(action) # Add the noiro-ssh filter to Svc Contract Subject print "\nAdding the noiro-ssh filter to Svc Contract Subject"