def __new__(cls, **params): res = utils.check_hostname(params['ip']) if res == 1: logger.warning("Host %s not answer" % (params['ip'])) logger.error("Device not created") return None return object.__new__(cls)
def check_rule(self, rule): if not utils.check_hostname(self.ip): return False res = False for r in self.chain.rules: if r == rule: res = True return res
def restart(self): logger.info("Restart %s" % (self.name)) if not utils.check_hostname(self.ip): print("Bad device") return False else: print("Good device") return True
def get_parameter(self, param): if utils.check_hostname(self.ip) == 1: return try: self.__conn.request("GET", "/axis-cgi/param.cgi?action=list&group=%s" % (param), headers=self.__headers_auth) res = self.__conn.getresponse() #logger.debug("%s %s", res.status, res.reason) data = res.read() return (data.split("=")[1]).strip() except httplib.HTTPException as e: logger.error("Execution failed: %s", e)
def remove_rule(self, rule): if not utils.check_hostname(self.ip): return False self.chain.delete_rule(rule) return True
def add_rule(self, rule): if not utils.check_hostname(self.ip): return False self.chain.insert_rule(rule) return True
def enable_rtsp(self): logger.info("Enable RTSP at %s" % (self.name)) if not utils.check_hostname(self.ip): return False else: return True