def main(): CONF.register_cli_opt(category_opt) try: utils.read_config('designate', sys.argv) logging.setup(CONF, 'designate') except cfg.ConfigFilesNotFoundError: cfgfile = CONF.config_file[-1] if CONF.config_file else None if cfgfile and not os.access(cfgfile, os.R_OK): st = os.stat(cfgfile) print(_("Could not read %s. Re-running with sudo") % cfgfile) try: os.execvp('sudo', ['sudo', '-u', '#%s' % st.st_uid] + sys.argv) except Exception: print(_('sudo failed, continuing as if nothing happened')) print(_('Please re-run designate-manage as root.')) sys.exit(2) utils.setup_gmr(log_dir=cfg.CONF.log_dir) hookpoints.log_hook_setup() fn = CONF.category.action_fn fn_args = fetch_func_args(fn) fn(*fn_args)
def main(): utils.read_config("designate", sys.argv) logging.setup("designate") server = mdns_service.Service.create(binary="designate-mdns") service.serve(server, workers=CONF["service:mdns"].workers) service.wait()
def main(): utils.read_config('designate', sys.argv) logging.setup('designate') server = sink_service.Service() service.serve(server, workers=CONF['service:sink'].workers) service.wait()
def main(): utils.read_config('designate', sys.argv) logging.setup(CONF, 'designate') gmr.TextGuruMeditation.setup_autorun(version) # NOTE(timsim): This is to ensure people don't start the wrong # services when the worker model is enabled. if cfg.CONF['service:worker'].enabled: LOG.error('You have designate-worker enabled, starting ' 'designate-zone-manager is incompatible with ' 'designate-worker. You need to start ' 'designate-producer instead.') sys.exit(1) debtcollector.deprecate('designate-zone-manager Is deprecated in ' 'favor of the designate-producer', version='newton', removal_version='rocky') LOG.warning('Starting designate-producer under the zone-manager name') server = producer_service.Service( threads=CONF['service:zone_manager'].threads) service.serve(server, workers=CONF['service:zone_manager'].workers) service.wait()
def main(): utils.read_config('designate', sys.argv) logging.setup(CONF, 'designate') gmr.TextGuruMeditation.setup_autorun(version) # NOTE(timsim): This is to ensure people don't start the wrong # services when the worker model is enabled. if cfg.CONF['service:worker'].enabled: LOG.error('You have designate-worker enabled, starting ' 'designate-pool-manager is incompatible with ' 'designate-worker. You need to start ' 'designate-worker instead.') sys.exit(1) debtcollector.deprecate('designate-pool-manager is deprecated in favor of ' 'designate-worker', version='newton', removal_version='rocky') server = pool_manager_service.Service( threads=CONF['service:pool_manager'].threads ) hookpoints.log_hook_setup() service.serve(server, workers=CONF['service:pool_manager'].workers) server.heartbeat_emitter.start() service.wait()
def main(): utils.read_config('designate', sys.argv) logging.setup(CONF, 'designate') utils.setup_gmr(log_dir=cfg.CONF.log_dir) server = agent_service.Service(threads=CONF['service:agent'].threads) service.serve(server, workers=CONF['service:agent'].workers) service.wait()
def main(): utils.read_config('designate', sys.argv) logging.setup(CONF, 'designate') utils.setup_gmr(log_dir=cfg.CONF.log_dir) server = api_service.Service(threads=CONF['service:api'].threads) launcher = service.launch(server, CONF['service:api'].workers) launcher.wait()
def main(): utils.read_config('designate', sys.argv) logging.setup('designate') server = pool_manager_service.Service.create( binary='designate-pool-manager') service.serve(server, workers=CONF['service:pool_manager'].workers) service.wait()
def main(): utils.read_config('designate', sys.argv) logging.setup('designate') server = central.Service.create(binary='designate-central', service_name='central') service.serve(server, workers=CONF['service:central'].workers) service.wait()
def main(): utils.read_config('designate', sys.argv) logging.setup('designate') server = agent_service.Service.create( binary='designate-agent') service.serve(server, workers=CONF['service:agent'].workers) service.wait()
def main(): # TODO(kiall): Support passing --config-file and --config-dir to # read_config utils.read_config('designate', []) logging.setup('designate') shell = DesignateShell() sys.exit(shell.run(sys.argv[1:]))
def main(): utils.read_config('designate', sys.argv) logging.setup(CONF, 'designate') gmr.TextGuruMeditation.setup_autorun(version) server = zone_manager_service.Service( threads=CONF['service:zone_manager'].threads) service.serve(server, workers=CONF['service:zone_manager'].workers) service.wait()
def main(): utils.read_config('designate', sys.argv) logging.setup('designate') rpc.init(CONF) launcher = service.launch(api_service.Service(), CONF['service:api'].workers) launcher.wait()
def main(): utils.read_config('designate', sys.argv) logging.setup(CONF, 'designate') gmr.TextGuruMeditation.setup_autorun(version) hookpoints.log_hook_setup() server = central.Service(threads=CONF['service:central'].threads) service.serve(server, workers=CONF['service:central'].workers) service.wait()
def main(): utils.read_config('designate', sys.argv) logging.setup(CONF, 'designate') utils.setup_gmr(log_dir=cfg.CONF.log_dir) hookpoints.log_hook_setup() server = central.Service(threads=CONF['service:central'].threads) service.serve(server, workers=CONF['service:central'].workers) service.wait()
def main(): utils.read_config('designate', sys.argv) logging.setup(CONF, 'designate') gmr.TextGuruMeditation.setup_autorun(version) hookpoints.log_hook_setup() server = mdns_service.Service(threads=CONF['service:mdns'].threads) service.serve(server, workers=CONF['service:mdns'].workers) server.heartbeat_emitter.start() service.wait()
def main(): CONF.register_cli_opt(category_opt) utils.read_config('designate', sys.argv) logging.setup(CONF, 'designate') gmr.TextGuruMeditation.setup_autorun(version) hookpoints.log_hook_setup() fn = CONF.category.action_fn fn_args = fetch_func_args(fn) fn(*fn_args)
def main(): cfg.CONF.register_cli_opt(command_opt) utils.read_config('designate', sys.argv) logging.setup('designate') func_kwargs = {} for k in cfg.CONF.command.action_kwargs: v = getattr(cfg.CONF.command, 'action_kwarg_' + k) if v is None: continue func_kwargs[k] = strutils.safe_decode(v) func_args = [strutils.safe_decode(arg) for arg in cfg.CONF.command.action_args] return cfg.CONF.command.action_fn(*func_args, **func_kwargs)
def main(): utils.read_config('designate', sys.argv) logging.setup(CONF, 'designate') gmr.TextGuruMeditation.setup_autorun(version) # NOTE(timsim): This is to ensure people don't start the wrong # services when the worker model is enabled. if not cfg.CONF['service:worker'].enabled: LOG.error('You do not have designate-worker enabled, starting ' 'designate-producer is not allowed. ' 'You need to start designate-zone-manager instead.') sys.exit(1) hookpoints.log_hook_setup() server = producer_service.Service(threads=CONF['service:producer'].threads) service.serve(server, workers=CONF['service:producer'].workers) service.wait()
def main(): utils.read_config('designate', sys.argv) logging.setup('designate') launcher = service.launch(sink_service.Service(), CONF['service:sink'].workers) launcher.wait()
def main(): # HACK HACK HACK - allow required config params to be passed # via the command line cfg.CONF['service:api']._group._opts['api_base_uri']['cli'] = True for optdict in cfg.CONF['backend:ipa']._group._opts.itervalues(): if 'cli' in optdict: optdict['cli'] = True # HACK HACK HACK - allow api url to be passed in the usual way utils.read_config('designate', sys.argv) if cfg.CONF['service:central'].backend_driver == 'ipa': raise CannotUseIPABackend(cuiberrorstr) if cfg.CONF.debug: LOG.setLevel(logging.DEBUG) elif cfg.CONF.verbose: LOG.setLevel(logging.INFO) else: LOG.setLevel(logging.WARN) ipabackend = impl_ipa.IPABackend(None) ipabackend.start() version = cfg.CONF['backend:ipa'].ipa_version designateurl = cfg.CONF['service:api'].api_base_uri + "v1" # get the list of domains/zones from IPA ipazones = getipadomains(ipabackend, version) # get unique list of name servers servers = {} for zonerec in ipazones: for nsrec in zonerec['nsrecord']: servers[nsrec] = nsrec if not servers: raise NoNameServers("Error: no name servers found in IPA") # let's see if designate is using the IPA backend # create a fake domain in IPA # create a fake server in Designate # try to create the same fake domain in Designate # if we get a DuplicateDomain error from Designate, then # raise the CannotUseIPABackend error, after deleting # the fake server and fake domain # find the first non-reverse zone zone = {} for zrec in ipazones: if not zrec['idnsname'][0].endswith("in-addr.arpa.") and \ zrec['idnszoneactive'][0] == 'TRUE': # ipa returns every data field as a list # convert the list to a scalar for n, v in list(zrec.items()): if n in zoneskips: continue if isinstance(v, list): zone[n] = v[0] else: zone[n] = v break assert(zone) # create a fake subdomain of this zone domname = "%s.%s" % (uuid.uuid4(), zone['idnsname']) args = copy.copy(zone) del args['idnsname'] args['version'] = version ipareq = {'method': 'dnszone_add', 'params': [[domname], args]} iparesp = ipabackend._call_and_handle_error(ipareq) LOG.debug("Response: %s" % pprint.pformat(iparesp)) if iparesp['error']: raise AddDomainError(pprint.pformat(iparesp)) # set up designate connection designatereq = requests.Session() xtra_hdrs = {'Content-Type': 'application/json'} designatereq.headers.update(xtra_hdrs) # sync ipa name servers to designate syncipaservers2des(servers, designatereq, designateurl) domainurl = designateurl + "/domains" # next, try to add the fake domain to Designate email = zone['idnssoarname'].rstrip(".").replace(".", "@", 1) desreq = {"name": domname, "ttl": int(zone['idnssoarefresh'][0]), "email": email} resp = designatereq.post(domainurl, data=json.dumps(desreq)) exc = None fakezoneid = None if resp.status_code == 200: LOG.info(_LI("Added domain %s") % domname) fakezoneid = resp.json()['id'] delresp = designatereq.delete(domainurl + "/" + fakezoneid) if delresp.status_code != 200: LOG.error(_LE("Unable to delete %(name)s: %(response)s") % {'name': domname, 'response': pprint.pformat( delresp.json())}) else: exc = CannotUseIPABackend(cuiberrorstr) # cleanup fake stuff ipareq = {'method': 'dnszone_del', 'params': [[domname], {'version': version}]} iparesp = ipabackend._call_and_handle_error(ipareq) LOG.debug("Response: %s" % pprint.pformat(iparesp)) if iparesp['error']: LOG.error(_LE("%s") % pprint.pformat(iparesp)) if exc: raise exc # get and delete existing domains resp = designatereq.get(domainurl) LOG.debug("Response: %s" % pprint.pformat(resp.json())) if resp and resp.status_code == 200 and resp.json() and \ 'domains' in resp.json(): # domains must be deleted in child/parent order i.e. delete # sub-domains before parent domains - simple way to get this # order is to sort the domains in reverse order of name len dreclist = sorted(resp.json()['domains'], key=lambda drec: len(drec['name']), reverse=True) for drec in dreclist: delresp = designatereq.delete(domainurl + "/" + drec['id']) if delresp.status_code != 200: raise DeleteDomainError("Unable to delete %s: %s" % (drec['name'], pprint.pformat(delresp.json()))) # key is zonename, val is designate rec id zonerecs = {} for zonerec in ipazones: desreq = zone2des(zonerec) resp = designatereq.post(domainurl, data=json.dumps(desreq)) if resp.status_code == 200: LOG.info(_LI("Added domain %s") % desreq['name']) else: raise AddDomainError("Unable to add domain %s: %s" % (desreq['name'], pprint.pformat(resp.json()))) zonerecs[desreq['name']] = resp.json()['id'] # get the records for each zone for zonename, domainid in list(zonerecs.items()): recurl = designateurl + "/domains/" + domainid + "/records" iparecs = getiparecords(ipabackend, zonename, version) for rec in iparecs: desreqs = rec2des(rec, zonename) for desreq in desreqs: resp = designatereq.post(recurl, data=json.dumps(desreq)) if resp.status_code == 200: LOG.info(_LI("Added record %(record)s " "for domain %(domain)s") % {'record': desreq['name'], 'domain': zonename}) else: raise AddRecordError("Could not add record %s: %s" % (desreq['name'], pprint.pformat(resp.json())))
pprint.pprint(payload) sys.stdout.flush() def sample(self, ctxt, publisher_id, event_type, payload, metadata): print "sample" pprint.pprint(payload) sys.stdout.flush() TRANSPORT_ALIASES = { 'designate.openstack.common.rpc.impl_kombu': 'rabbit', 'designate.openstack.common.rpc.impl_qpid': 'qpid', 'designate.openstack.common.rpc.impl_zmq': 'zmq', 'designate.rpc.impl_kombu': 'rabbit', 'designate.rpc.impl_qpid': 'qpid', 'designate.rpc.impl_zmq': 'zmq', } utils.read_config('designate', sys.argv) logging.setup('designate') transport = messaging.get_transport(cfg.CONF, aliases=TRANSPORT_ALIASES) targets = [ messaging.Target(exchange='nova', topic='notifications'), messaging.Target(exchange='neutron', topic='notifications') ] endpoints = [NotificationEndpoint()] server = messaging.get_notification_listener(transport, targets, endpoints) server.start() server.wait()
def main(): # HACK HACK HACK - allow required config params to be passed # via the command line cfg.CONF['service:api']._group._opts['api_base_uri']['cli'] = True for optdict in cfg.CONF['backend:ipa']._group._opts.itervalues(): if 'cli' in optdict: optdict['cli'] = True # HACK HACK HACK - allow api url to be passed in the usual way utils.read_config('designate', sys.argv) if cfg.CONF['service:central'].backend_driver == 'ipa': raise CannotUseIPABackend(cuiberrorstr) if cfg.CONF.debug: LOG.setLevel(logging.DEBUG) elif cfg.CONF.verbose: LOG.setLevel(logging.INFO) else: LOG.setLevel(logging.WARN) ipabackend = impl_ipa.IPABackend(None) ipabackend.start() version = cfg.CONF['backend:ipa'].ipa_version designateurl = cfg.CONF['service:api'].api_base_uri + "v1" # get the list of domains/zones from IPA ipazones = getipadomains(ipabackend, version) # get unique list of name servers servers = {} for zonerec in ipazones: for nsrec in zonerec['nsrecord']: servers[nsrec] = nsrec if not servers: raise NoNameServers("Error: no name servers found in IPA") # let's see if designate is using the IPA backend # create a fake domain in IPA # create a fake server in Designate # try to create the same fake domain in Designate # if we get a DuplicateDomain error from Designate, then # raise the CannotUseIPABackend error, after deleting # the fake server and fake domain # find the first non-reverse zone zone = {} for zrec in ipazones: if not zrec['idnsname'][0].endswith("in-addr.arpa.") and \ zrec['idnszoneactive'][0] == 'TRUE': # ipa returns every data field as a list # convert the list to a scalar for n, v in zrec.iteritems(): if n in zoneskips: continue if isinstance(v, list): zone[n] = v[0] else: zone[n] = v break assert(zone) # create a fake subdomain of this zone domname = "%s.%s" % (uuid.uuid4(), zone['idnsname']) args = copy.copy(zone) del args['idnsname'] args['version'] = version ipareq = {'method': 'dnszone_add', 'params': [[domname], args]} iparesp = ipabackend._call_and_handle_error(ipareq) LOG.debug("Response: %s" % pprint.pformat(iparesp)) if iparesp['error']: raise AddDomainError(pprint.pformat(iparesp)) # set up designate connection designatereq = requests.Session() xtra_hdrs = {'Content-Type': 'application/json'} designatereq.headers.update(xtra_hdrs) # sync ipa name servers to designate syncipaservers2des(servers, designatereq, designateurl) domainurl = designateurl + "/domains" # next, try to add the fake domain to Designate email = zone['idnssoarname'].rstrip(".").replace(".", "@", 1) desreq = {"name": domname, "ttl": int(zone['idnssoarefresh'][0]), "email": email} resp = designatereq.post(domainurl, data=json.dumps(desreq)) exc = None fakezoneid = None if resp.status_code == 200: LOG.info(_LI("Added domain %s") % domname) fakezoneid = resp.json()['id'] delresp = designatereq.delete(domainurl + "/" + fakezoneid) if delresp.status_code != 200: LOG.error(_LE("Unable to delete %(name)s: %(response)s") % {'name': domname, 'response': pprint.pformat( delresp.json())}) else: exc = CannotUseIPABackend(cuiberrorstr) # cleanup fake stuff ipareq = {'method': 'dnszone_del', 'params': [[domname], {'version': version}]} iparesp = ipabackend._call_and_handle_error(ipareq) LOG.debug("Response: %s" % pprint.pformat(iparesp)) if iparesp['error']: LOG.error(_LE("%s") % pprint.pformat(iparesp)) if exc: raise exc # get and delete existing domains resp = designatereq.get(domainurl) LOG.debug("Response: %s" % pprint.pformat(resp.json())) if resp and resp.status_code == 200 and resp.json() and \ 'domains' in resp.json(): # domains must be deleted in child/parent order i.e. delete # sub-domains before parent domains - simple way to get this # order is to sort the domains in reverse order of name len dreclist = sorted(resp.json()['domains'], key=lambda drec: len(drec['name']), reverse=True) for drec in dreclist: delresp = designatereq.delete(domainurl + "/" + drec['id']) if delresp.status_code != 200: raise DeleteDomainError("Unable to delete %s: %s" % (drec['name'], pprint.pformat(delresp.json()))) # key is zonename, val is designate rec id zonerecs = {} for zonerec in ipazones: desreq = zone2des(zonerec) resp = designatereq.post(domainurl, data=json.dumps(desreq)) if resp.status_code == 200: LOG.info(_LI("Added domain %s") % desreq['name']) else: raise AddDomainError("Unable to add domain %s: %s" % (desreq['name'], pprint.pformat(resp.json()))) zonerecs[desreq['name']] = resp.json()['id'] # get the records for each zone for zonename, domainid in zonerecs.iteritems(): recurl = designateurl + "/domains/" + domainid + "/records" iparecs = getiparecords(ipabackend, zonename, version) for rec in iparecs: desreqs = rec2des(rec, zonename) for desreq in desreqs: resp = designatereq.post(recurl, data=json.dumps(desreq)) if resp.status_code == 200: LOG.info(_LI("Added record %(record)s " "for domain %(domain)s") % {'record': desreq['name'], 'domain': zonename}) else: raise AddRecordError("Could not add record %s: %s" % (desreq['name'], pprint.pformat(resp.json())))
def sample(self, ctxt, publisher_id, event_type, payload, metadata): print "sample" pprint.pprint(payload) sys.stdout.flush() TRANSPORT_ALIASES = { 'designate.openstack.common.rpc.impl_kombu': 'rabbit', 'designate.openstack.common.rpc.impl_qpid': 'qpid', 'designate.openstack.common.rpc.impl_zmq': 'zmq', 'designate.rpc.impl_kombu': 'rabbit', 'designate.rpc.impl_qpid': 'qpid', 'designate.rpc.impl_zmq': 'zmq', } utils.read_config('designate', sys.argv) logging.setup('designate') transport = messaging.get_transport(cfg.CONF, aliases=TRANSPORT_ALIASES) targets = [ messaging.Target(exchange='nova', topic='notifications'), messaging.Target(exchange='neutron', topic='notifications') ] endpoints = [ NotificationEndpoint() ] server = messaging.get_notification_listener(transport, targets, endpoints) server.start() server.wait()