# Path: clearstack/controller.py
# class Controller:
#     CONF = {}
#     _plugins = []
#     _groups = []
#     _sequences = []
# 
#     def add_sequence(self, desc, function, args=None):
#         self._sequences.append(Sequence(desc, function, args))
# 
#     def run_all_sequences(self):
#         for seq in self._sequences:
#             try:
#                 seq.run()
#             except Exception as e:
#                 raise e
# 
#     def add_plugin(self, plugin):
#         self._plugins.append(plugin)
# 
#     def get_all_plugins(self):
#         return self._plugins
# 
#     def add_group(self, name, args):
#         self._groups.append(Group(name, args))
# 
#     def get_all_groups(self):
#         return self._groups
# 
#     def get_all_arguments(self):
#         """Get a list of the configuration argument loaded"""
#         arguments = []
#         for group in self._groups:
#             arguments.extend([argument.conf_name
#                               for argument in group.get_all_arguments()])
#         return arguments
# 
#     def validate_groups(self, conf_values):
#         """ Load validation functions, in order to check
#         the values in the answer file """
#         arguments = {}
#         for group in self._groups:
#             for arg in group.get_all_arguments():
#                 try:
#                     arg.validate(conf_values[arg.conf_name])
#                 except Exception as e:
#                     raise Exception("{0}: {1}".format(arg.conf_name, str(e)))
#         return arguments
# 
# Path: clearstack/common/util.py
# HOST_LOG_DIR = '/var/log/clearstack'
# HOST_LOG_FILE = "{0}/clearstack.log".format(HOST_LOG_DIR)
# LOG_DIR = '/var/log/clearstack'
#     LOG_DIR = '/tmp/log/clearstack'
# LOG_FILE = "{0}/clearstack.log".format(LOG_DIR)
# LOG = logging.getLogger("Clearstack")
# def _print_error_message(self, e, file_name):
# def port_open(port):
# def service_status(service):
# def service_enabled(service):
# def setup_debugging(debug, is_remote_host=True):
# def run_command(command, stdin=None, environ=None, debug=True):
# def str2bool(value):
# def write_config(file, data):
# def write_properties(file, data):
# def get_option(file, section, option):
# def delete_option(file, section, option=None):
# def write_in_file_ine(file, data):
# def get_dns():
# def get_netmask():
# def get_gateway():
# def get_net_interface():
# def get_ips():
# def get_nic(ip):
# def get_ip():
# def find_my_ip_from_config(config_ips):
# def is_localhost(host):
# def has_localhost(hosts):
# def remove_localhost(hosts):
# def ensure_directory(dir):
# def link_file(source, target):
# 
# Path: clearstack/common/util.py
# LOG = logging.getLogger("Clearstack")
# 
# Path: clearstack/common/singleton.py
# class Singleton:
#     def __init__(self, decorated):
#         self._decorated = decorated
# 
#     def get(self):
#         try:
#             return self._instance
#         except AttributeError:
#             self._instance = self._decorated()
#             return self._instance
# 
#     def __call__(self):
#         raise TypeError('Singletons must be accessed through `Get()`.')
# 
#     def __instancecheck__(self, inst):
#         return isinstance(inst, self._decorated)


import os
import paramiko
from clearstack.controller import Controller
from clearstack.common import util
from clearstack.common.util import LOG
from clearstack.common.singleton import Singleton
            except IOError:
                pass
            for dirpath, dirnames, filenames in os.walk(file):
                remote_path = dest_path + dirpath.split(parent_dir)[1]
                try:
                    sftp.mkdir(remote_path)
                except:
                    LOG.info("clearstack: Directory {0} is already created"
                             "in remote host".format(remote_path))
                for filename in filenames:
                    local_path = os.path.join(dirpath, filename)
                    remote_filepath = os.path.join(remote_path, filename)
                    sftp.put(local_path, remote_filepath)
        else:
            filename = file.split('/')[-1]
            sftp.put(file, "{0}/{1}".format(dest_path, filename))

        connection.close()

    def test_python_in_host(self, host, connection):
        try:
            stdin, stdout, stderr = self.run_command(connection,
                                                     'python3 --version')
        except:
            raise Exception("cannot run python3 in {0},"
                            " please install python3".format(host))

    def test_hosts(self, _hosts):
        hosts = set(_hosts)
        connection = None

# Path: clearstack/controller.py
# class Controller:
#     CONF = {}
#     _plugins = []
#     _groups = []
#     _sequences = []
# 
#     def add_sequence(self, desc, function, args=None):
#         self._sequences.append(Sequence(desc, function, args))
# 
#     def run_all_sequences(self):
#         for seq in self._sequences:
#             try:
#                 seq.run()
#             except Exception as e:
#                 raise e
# 
#     def add_plugin(self, plugin):
#         self._plugins.append(plugin)
# 
#     def get_all_plugins(self):
#         return self._plugins
# 
#     def add_group(self, name, args):
#         self._groups.append(Group(name, args))
# 
#     def get_all_groups(self):
#         return self._groups
# 
#     def get_all_arguments(self):
#         """Get a list of the configuration argument loaded"""
#         arguments = []
#         for group in self._groups:
#             arguments.extend([argument.conf_name
#                               for argument in group.get_all_arguments()])
#         return arguments
# 
#     def validate_groups(self, conf_values):
#         """ Load validation functions, in order to check
#         the values in the answer file """
#         arguments = {}
#         for group in self._groups:
#             for arg in group.get_all_arguments():
#                 try:
#                     arg.validate(conf_values[arg.conf_name])
#                 except Exception as e:
#                     raise Exception("{0}: {1}".format(arg.conf_name, str(e)))
#         return arguments
# 
# Path: clearstack/common/util.py
# HOST_LOG_DIR = '/var/log/clearstack'
# HOST_LOG_FILE = "{0}/clearstack.log".format(HOST_LOG_DIR)
# LOG_DIR = '/var/log/clearstack'
#     LOG_DIR = '/tmp/log/clearstack'
# LOG_FILE = "{0}/clearstack.log".format(LOG_DIR)
# LOG = logging.getLogger("Clearstack")
# def _print_error_message(self, e, file_name):
# def port_open(port):
# def service_status(service):
# def service_enabled(service):
# def setup_debugging(debug, is_remote_host=True):
# def run_command(command, stdin=None, environ=None, debug=True):
# def str2bool(value):
# def write_config(file, data):
# def write_properties(file, data):
# def get_option(file, section, option):
# def delete_option(file, section, option=None):
# def write_in_file_ine(file, data):
# def get_dns():
# def get_netmask():
# def get_gateway():
# def get_net_interface():
# def get_ips():
# def get_nic(ip):
# def get_ip():
# def find_my_ip_from_config(config_ips):
# def is_localhost(host):
# def has_localhost(hosts):
# def remove_localhost(hosts):
# def ensure_directory(dir):
# def link_file(source, target):
# 
# Path: clearstack/common/util.py
# LOG = logging.getLogger("Clearstack")
# 
# Path: clearstack/common/singleton.py
# class Singleton:
#     def __init__(self, decorated):
#         self._decorated = decorated
# 
#     def get(self):
#         try:
#             return self._instance
#         except AttributeError:
#             self._instance = self._decorated()
#             return self._instance
# 
#     def __call__(self):
#         raise TypeError('Singletons must be accessed through `Get()`.')
# 
#     def __instancecheck__(self, inst):
#         return isinstance(inst, self._decorated)


# Path: clearstack/ssh.py
import os
import paramiko
from clearstack.controller import Controller
from clearstack.common import util
from clearstack.common.util import LOG
from clearstack.common.singleton import Singleton

            except IOError:
                pass
            for dirpath, dirnames, filenames in os.walk(file):
                remote_path = dest_path + dirpath.split(parent_dir)[1]
                try:
                    sftp.mkdir(remote_path)
                except:
                    LOG.info("clearstack: Directory {0} is already created"
                             "in remote host".format(remote_path))
                for filename in filenames:
                    local_path = os.path.join(dirpath, filename)
                    remote_filepath = os.path.join(remote_path, filename)
                    sftp.put(local_path, remote_filepath)
        else:
            filename = file.split('/')[-1]
            sftp.put(file, "{0}/{1}".format(dest_path, filename))

        connection.close()

    def test_python_in_host(self, host, connection):
        try:
            stdin, stdout, stderr = self.run_command(connection,
                                                     'python3 --version')
        except:
            raise Exception("cannot run python3 in {0},"
                            " please install python3".format(host))

    def test_hosts(self, _hosts):
        hosts = set(_hosts)
        connection = None

        conf = Controller.get().CONF