def DELETE(self, autostackId, metricId): # pylint: disable=C0103,R0201 """ Remove a specific metric from autostack :: DELETE /_autostacks/{autostackId}/metrics/{metricId} """ try: # The if statement makes sure that the metric belongs to the autostack with web.ctx.connFactory() as conn: autostackObj = repository.getAutostackFromMetric(conn, metricId) if autostackId != autostackObj.uid: raise InvalidRequestResponse( {"result": "Metric=%s does not belong to autostack=%s" % (metricId, autostackId)}) with web.ctx.connFactory() as conn: repository.deleteMetric(conn, metricId) model_swapper_utils.deleteHTMModel(metricId) raise web.HTTPError(status="204 No Content") except ObjectNotFoundError: raise web.notfound(("Autostack or metric not found: autostack=%s, " "metric=%s") % (autostackId, metricId)) except web.HTTPError as ex: if bool(re.match(r"([45][0-9][0-9])\s?", web.ctx.status)): # Log 400-599 status codes as errors, ignoring 200-399 log.error(str(ex) or repr(ex)) raise except Exception as ex: log.exception("DELETE Failed") raise web.internalerror(str(ex) or repr(ex))
def DELETE(self, autostackId): # pylint: disable=C0103,R0201 """ Delete an Autostack :: DELETE /_autostacks/{autostackId} """ try: with web.ctx.connFactory() as conn: modelIDs = tuple( m.uid for m in repository.getAutostackMetrics(conn, autostackId)) with web.ctx.connFactory() as conn: repository.deleteAutostack(conn, autostackId) # Delete the corresponding Engine models, if any for modelID in modelIDs: model_swapper_utils.deleteHTMModel(modelID) raise web.HTTPError(status="204 No Content") except ObjectNotFoundError: raise web.notfound("Autostack not found: Autostack ID: %s" % autostackId) except web.HTTPError as ex: if bool(re.match(r"([45][0-9][0-9])\s?", web.ctx.status)): # Log 400-599 status codes as errors, ignoring 200-399 log.error(str(ex) or repr(ex)) raise except Exception as ex: log.exception("DELETE Failed") raise web.internalerror(str(ex) or repr(ex))
def DELETE(self, autostackId): # pylint: disable=C0103,R0201 """ Delete an Autostack :: DELETE /_autostacks/{autostackId} """ try: with web.ctx.connFactory() as conn: modelIDs = tuple(m.uid for m in repository. getAutostackMetrics(conn, autostackId)) with web.ctx.connFactory() as conn: repository.deleteAutostack(conn, autostackId) # Delete the corresponding Engine models, if any for modelID in modelIDs: model_swapper_utils.deleteHTMModel(modelID) raise web.HTTPError(status="204 No Content") except ObjectNotFoundError: raise web.notfound("Autostack not found: Autostack ID: %s" % autostackId) except web.HTTPError as ex: if bool(re.match(r"([45][0-9][0-9])\s?", web.ctx.status)): # Log 400-599 status codes as errors, ignoring 200-399 log.error(str(ex) or repr(ex)) raise except Exception as ex: log.exception("DELETE Failed") raise web.internalerror(str(ex) or repr(ex))
def unmonitorMetric(self, metricId): """ Unmonitor a metric :param metricId: unique identifier of the metric row :raises grok.app.exceptions.ObjectNotFoundError: if metric with the referenced metric uid doesn't exist """ # Delete the metric from the database with self.connectionFactory() as conn: repository.retryOnTransientErrors(repository.deleteMetric)(conn, metricId) # Send request to delete HTM model model_swapper_utils.deleteHTMModel(metricId) self._log.info("Cloudwatch Metric unmonitored: metric=%r", metricId)
def unmonitorMetric(self, metricId): """ Unmonitor a metric :param metricId: unique identifier of the metric row :raises htm.it.app.exceptions.ObjectNotFoundError: if metric with the referenced metric uid doesn't exist """ # Delete the metric from the database with self.connectionFactory() as conn: repository.retryOnTransientErrors(repository.deleteMetric)( conn, metricId) # Send request to delete HTM model model_swapper_utils.deleteHTMModel(metricId) self._log.info("Cloudwatch Metric unmonitored: metric=%r", metricId)
def unmonitorMetric(self, metricId): """ Unmonitor a metric :param metricId: unique identifier of the metric row :raises htmengine.exceptions.ObjectNotFoundError: if metric with the referenced metric uid doesn't exist """ @repository.retryOnTransientErrors def updateMetric(): with self.connectionFactory() as conn: repository.deleteModel(conn, metricId) updateMetric() model_swapper_utils.deleteHTMModel(metricId) self._log.info("HTM Metric unmonitored: metric=%r", metricId)