+ Returns
+ -------
+ bool
+ whether or not the xapp is registered
+ """
+ hostname = os.environ.get("HOSTNAME")
+ xappname = self._config_data.get("name")
+ xappversion = self._config_data.get("version")
+ pltnamespace = os.environ.get("PLT_NAMESPACE")
+ if pltnamespace is None:
+ pltnamespace = Constants.DEFAULT_PLT_NS
+ self.logger.debug("config details hostname : {} xappname: {} xappversion : {} pltnamespace : {}".format(
+ hostname, xappname, xappversion, pltnamespace))
+
+ http_endpoint = self.get_service(hostname, Constants.SERVICE_HTTP)
+ rmr_endpoint = self.get_service(hostname, Constants.SERVICE_RMR)
+ if http_endpoint == "" or rmr_endpoint == "":
+ self.logger.error(
+ "Couldn't resolve service endpoints: http_endpoint={} rmr_endpoint={}".format(http_endpoint,
+ rmr_endpoint))
+ return False
+ self.logger.debug(
+ "config details hostname : {} xappname: {} xappversion : {} pltnamespace : {} http_endpoint : {} rmr_endpoint "
+ ": {} configpath : {}".format(hostname, xappname, xappversion, pltnamespace, http_endpoint, rmr_endpoint,
+ self._config_data.get("CONFIG_PATH")))
+ request_string = {
+ "appName": hostname,
+ "appVersion": xappversion,
+ "configPath": "",
+ "appInstanceName": xappname,
+ "httpEndpoint": http_endpoint,
+ "rmrEndpoint": rmr_endpoint,
+ "config": json.dumps(self._config_data)
+ }
+ self.logger.info("REQUEST STRING :{}".format(request_string))
+ return self.do_post(pltnamespace, Constants.REGISTER_PATH, request_string)
+
+ def registerXapp(self):
+ """
+ registers the xapp
+ """
+ retries = 5
+ while self._keep_registration and retries > 0:
+ time.sleep(2)
+ retries = retries-1
+ # checking for rmr/sdl/xapp health
+ healthy = self.healthcheck()
+ if not healthy:
+ self.logger.warning(
+ "Application='{}' is not ready yet, waiting ...".format(self._config_data.get("name")))
+ continue
+
+ self.logger.debug("Application='{}' is now up and ready, continue with registration ...".format(
+ self._config_data.get("name")))
+ if self.register():
+ self.logger.debug("Registration done, proceeding with startup ...")
+ break
+
+ def deregister(self):