def on_initial_bootstrap(self, process, config, **kwargs): """ Bootstraps initial objects in the system from configuration (pyon.yml) via EMS calls. """ # get default org_id # @TODO: single org assumed for now org_ids = process.container.resource_registry.find_resources( RT.Org, id_only=True) if not (len(org_ids) and len(org_ids[0]) == 1): raise StandardError("Could not determine org_id") org_id = org_ids[0][0] ems_client = ExchangeManagementServiceProcessClient(process=process) # # Create XSs and XPs # for xsname, xsdict in config.get_safe('exchange_spaces', {}).iteritems(): xso = ResExchangeSpace(name=xsname) xso_id = ems_client.create_exchange_space(xso, org_id) log.info("ExchangeSpace %s, id %s", xsname, xso_id) for xpname, xpopts in xsdict.get('exchange_points', {}).iteritems(): # @TODO: some translation for types CFG currentl has it as "topic_tree" and we've been using "ttree" ttype = xpopts.get('type', 'topic_tree') if ttype == "topic_tree": ttype = "ttree" xpo = ResExchangePoint(name=xpname, topology_type=ttype) xpo_id = ems_client.create_exchange_point(xpo, xso_id) log.info("\tExchangePoint %s, id %s", xpname, xpo_id) # # Create and associate brokers with XSs # for brokername in xsdict.get('brokers', []): xbo = ResExchangeBroker(name=brokername) xbo_id = ems_client.create_exchange_broker(xbo) log.info("\tExchangeBroker %s, id %s", brokername, xbo_id) # directly associate broker with XS # @TODO: should EMS provide this? # first find out if the assoc exists already assocs = process.container.resource_registry.find_associations( xso_id, PRED.hasExchangeBroker, id_only=True) if len(assocs) > 0: continue process.container.resource_registry.create_association( xso_id, PRED.hasExchangeBroker, xbo_id)
def on_initial_bootstrap(self, process, config, **kwargs): """ Bootstraps initial objects in the system from configuration (pyon.yml) via EMS calls. """ # Get ION Org root_org_name = config.get_safe('system.root_org' , "ION") org_ids, _ = process.container.resource_registry.find_resources(restype=RT.Org, name=root_org_name, id_only=True) if not org_ids or len(org_ids) > 1: raise StandardError("Could not determine root Org") org_id = org_ids[0] ems_client = ExchangeManagementServiceProcessClient(process=process) # Create XSs and XPs resource objects xs_by_name = {} # Name to resource ID mapping for ExchangeSpace xs_defs = config.get_safe("exchange.exchange_spaces", {}) for xsname, xsdict in xs_defs.iteritems(): xso = ResExchangeSpace(name=xsname, description=xsdict.get("description", "")) xso_id = ems_client.create_exchange_space(xso, org_id) xs_by_name[xsname] = xso_id log.info("ExchangeSpace %s, id %s", xsname, xso_id) for xpname, xpopts in xsdict.get("exchange_points", {}).iteritems(): # Translation for types. CFG currently has it as "topic_tree" and Pyon uses "ttree" xpo = ResExchangePoint(name=xpname, description=xpopts.get("description", ""), topology_type=xpopts.get('type', 'ttree')) xpo_id = ems_client.create_exchange_point(xpo, xso_id) log.info("\tExchangePoint %s, id %s", xpname, xpo_id) # Create XSs and XPs resource objects for brokername, bdict in config.get_safe("exchange.exchange_brokers", {}).iteritems(): xbo = ResExchangeBroker(name=brokername, description=bdict.get("description", "")) xbo_id = ems_client.create_exchange_broker(xbo) log.info("\tExchangeBroker %s, id %s", brokername, xbo_id) for xs_name in bdict.get("join_xs", []): if xs_name in xs_by_name: xs_id = xs_by_name[xs_name] # directly associate broker with XS # @TODO: should EMS provide this? # first find out if the assoc exists already assocs = process.container.resource_registry.find_associations(xso_id, PRED.hasExchangeBroker, id_only=True) if len(assocs) > 0: continue process.container.resource_registry.create_association(xso_id, PRED.hasExchangeBroker, xbo_id) else: log.warn("ExchangeSpace %s unknown. Broker %s cannot join", xs_name, brokername) for xp_name in bdict.get("join_xp", []): pass
def on_initial_bootstrap(self, process, config, **kwargs): """ Bootstraps initial objects in the system from configuration (pyon.yml) via EMS calls. """ # get default org_id # @TODO: single org assumed for now org_ids = process.container.resource_registry.find_resources(RT.Org, id_only=True) if not (len(org_ids) and len(org_ids[0]) == 1): raise StandardError("Could not determine org_id") org_id = org_ids[0][0] ems_client = ExchangeManagementServiceProcessClient(process=process) # # Create XSs and XPs # for xsname, xsdict in config.get_safe('exchange_spaces', {}).iteritems(): xso = ResExchangeSpace(name=xsname) xso_id = ems_client.create_exchange_space(xso, org_id) log.info("ExchangeSpace %s, id %s", xsname, xso_id) for xpname, xpopts in xsdict.get('exchange_points', {}).iteritems(): # @TODO: some translation for types CFG currentl has it as "topic_tree" and we've been using "ttree" ttype = xpopts.get('type', 'topic_tree') if ttype == "topic_tree": ttype = "ttree" xpo = ResExchangePoint(name=xpname, topology_type=ttype) xpo_id = ems_client.create_exchange_point(xpo, xso_id) log.info("\tExchangePoint %s, id %s", xpname, xpo_id) # # Create and associate brokers with XSs # for brokername in xsdict.get('brokers', []): xbo = ResExchangeBroker(name=brokername) xbo_id = ems_client.create_exchange_broker(xbo) log.info("\tExchangeBroker %s, id %s", brokername, xbo_id) # directly associate broker with XS # @TODO: should EMS provide this? # first find out if the assoc exists already assocs = process.container.resource_registry.find_associations(xso_id, PRED.hasExchangeBroker, id_only=True) if len(assocs) > 0: continue process.container.resource_registry.create_association(xso_id, PRED.hasExchangeBroker, xbo_id)