def check_ret(self, string, path, ret, updated_result): if ret.status_code != 200: LOG.info(_LI("%(str)s ELEMENT result code: %(stat)d " "%(path)s %(reason)s text=%(text)s"), {'str': string, 'path': path, 'stat': ret.status_code, 'reason': ret.reason, 'text': ret.text}) updated_result.type = "text" updated_result.result = ret.text else: if ret.headers.get('content-type') == "application/json": updated_result.type = "json" updated_result.result = ret.json else: updated_result.type = "text" updated_result.result = ret.content updated_result.code = ret.status_code
def firewall_deleted(self, context, firewall_id, **kwargs): """Agent uses this to indicate firewall is deleted.""" LOG.debug("firewall_deleted() called") try: with context.session.begin(subtransactions=True): fw_db = self.plugin._get_firewall(context, firewall_id) # allow to delete firewalls in ERROR state if fw_db.status in (nl_constants.PENDING_DELETE, nl_constants.ERROR): self.plugin.delete_db_firewall_object(context, firewall_id) return True else: LOG.warning(_LW('Firewall %(fw)s unexpectedly deleted by ' 'agent, status was %(status)s'), {'fw': firewall_id, 'status': fw_db.status}) fw_db.update({"status": nl_constants.ERROR}) return False except fw_ext.FirewallNotFound: LOG.info(_LI('Firewall %s already deleted'), firewall_id) return True
def check_ret(self, string, path, ret, updated_result): if ret.status_code != 200: LOG.info( _LI("%(str)s ELEMENT result code: %(stat)d " "%(path)s %(reason)s text=%(text)s"), { 'str': string, 'path': path, 'stat': ret.status_code, 'reason': ret.reason, 'text': ret.text }) updated_result.type = "text" updated_result.result = ret.text else: if ret.headers.get('content-type') == "application/json": updated_result.type = "json" updated_result.result = ret.json else: updated_result.type = "text" updated_result.result = ret.content updated_result.code = ret.status_code