Пример #1
0
 def setup_logger(self):
     path = UserDefaults.log_path()
     dirname = os.path.dirname(path)
     if not os.path.exists(dirname):
         os.makedirs(dirname, 0o770)
     logger = logging.getLogger('opsmop')
     logger.setLevel(logging.DEBUG)
     handler = logging.handlers.RotatingFileHandler(path,
                                                    maxBytes=1024 * 5000,
                                                    backupCount=5)
     formatter = logging.Formatter(UserDefaults.log_format())
     handler.setFormatter(formatter)
     logger.addHandler(handler)
     return logger
Пример #2
0
    def process_remote_role(self, policy, role):
        """
        Processes one role in any mode
        """

        import dill

        self.connection_manager.announce_role(role)
        hosts = role.inventory().hosts()
        self.connection_manager.add_hosts(hosts)

        batch_size = role.serial()
        max_workers = UserDefaults.max_workers()

        self.compute_max_hostname_length(hosts)
        self.connection_manager.prepare_for_role(role)
        self.connect_to_all_hosts(hosts, role, max_workers)
        self.run_roles_on_all_hosts(hosts, policy, role, batch_size)
        self.connection_manager.event_loop()
        self.process_summary(hosts)
Пример #3
0
 def check_host_keys(self):
     return self.variables.get('opsmop_ssh_check_host_keys',
                               UserDefaults.ssh_check_host_keys())
Пример #4
0
 def sudo_password(self):
     return self.variables.get('opsmop_sudo_password',
                               UserDefaults.sudo_password())
Пример #5
0
 def sudo_username(self):
     return self.variables.get('opsmop_sudo_username',
                               UserDefaults.sudo_username())
Пример #6
0
 def check_host_keys(self):
     return UserDefaults.ssh_check_host_keys()
Пример #7
0
 def sudo_as(self):
     return (UserDefaults.sudo_username(), UserDefaults.sudo_password())
Пример #8
0
 def ssh_as(self):
     return (UserDefaults.ssh_username(), UserDefaults.ssh_password())
Пример #9
0
 def python_path(self):
     return self.variables.get('opsmop_python_path',
                               UserDefaults.python_path())