Exemplo n.º 1
0
 def test_root(self):
     command = "service ssh status"
     tasks = {"test_root": command}
     try:
         response = execute(self, tasks, become=True)
     except Exception as e:
         logger.error(str(e))
         return False
     logger.debug("output : " + str(response))
     return True
Exemplo n.º 2
0
 def test(self):
     command = "cat /etc/hostname"
     tasks = {"test": command}
     try:
         response = execute(self, tasks)
     except Exception as e:
         self.get_logger().error(str(e))
         return False
     logger.debug("output : " + str(response))
     return True
Exemplo n.º 3
0
 def reload(self):
     if self.server.os.name == 'debian':
         command = "service " + self.__class__.__name__.lower() + " reload"
     else:
         raise Exception("Not yet implemented")
     tasks = {"reload": command}
     try:
         response = execute(self.server, tasks, become=True)
     except Exception as e:
         self.get_logger().error(str(e))
         return {'status': False, 'errors': str(e)}
     self.get_logger().debug("output : " + str(response))
     return {'status': True}
Exemplo n.º 4
0
 def status(self):
     if self.server.os.name == 'debian':
         command = "service " + self.__class__.__name__.lower() + " status"
     else:
         raise Exception("Not yet implemented")
     tasks = {"status": command}
     try:
         response = execute(self.server, tasks, become=True)
     except Exception as e:
         self.get_logger().error('Failed to get status : ' + str(e))
         return 'Failed to get status : ' + str(e)
     self.get_logger().debug("output : " + str(response))
     return response['status']
Exemplo n.º 5
0
 def install(self):
     if self.server.os.name == 'debian':
         command1 = "apt update"
         command2 = "apt install " + self.__class__.__name__.lower()
     else:
         raise Exception("Not yet implemented")
     tasks = {"update": command1, "install": command2}
     try:
         response = execute(self.server, tasks, become=True)
     except Exception as e:
         self.get_logger().error(str(e))
         return {'status': False, 'errors': str(e)}
     self.get_logger().debug("output : " + str(response))
     return {'status': True}
Exemplo n.º 6
0
 def uptime(self):
     if self.server.os.name == 'debian':
         command = "ps -eo lstart\=,cmd | grep " + self.type.lower(
         ) + " | sed -n '3 p'  |  cut -d '/' -f 1"
     else:
         raise Exception("Not yet implemented")
     tasks = {"uptime": command}
     try:
         response = execute(self.server, tasks)
     except Exception as e:
         logger.error(str(e))
         return 'Failed to get the uptime on the host : ' + str(e)
     logger.debug("output : " + str(response))
     return response['uptime']