Exemple #1
0
 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)
Exemple #2
0
 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
Exemple #3
0
 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
Exemple #4
0
 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)
Exemple #5
0
 def remove_rule(self, rule):
     if not utils.check_hostname(self.ip):
         return False
     self.chain.delete_rule(rule)
     return True
Exemple #6
0
 def add_rule(self, rule):
     if not utils.check_hostname(self.ip):
         return False
     self.chain.insert_rule(rule)
     return True
Exemple #7
0
 def enable_rtsp(self):
     logger.info("Enable RTSP at %s" % (self.name))
     if not utils.check_hostname(self.ip):
         return False
     else:
         return True