예제 #1
0
class _PodChaos:
    def __init__(self, test_env=None):
        self.__env = test_env if test_env else "DEFAULT"

        self.__config = ConfigUtil(self.__env)
        self.__namespace = self.__config.get_pod_namespace()
        self.__linux = Shell(self.__config.get_main_server_ip(),
                             self.__config.get_authority_user(),
                             self.__config.get_authority_pwd())
        self.__log = Log.MyLog()

    def pod_kill(self, pod_name):
        if not pod_name:
            ExceptionHandler.raise_up(
                'Failed to kill pod, please provide the name of target pod')

        LDB_ChaosTest.pod_kill(pod_name, self.__namespace)

    def enable_pod_failure(self, pod_name=None):
        if not pod_name:
            ExceptionHandler.raise_up(
                'Failed to enable pod failure, please provide the name of target pod'
            )

        LDB_ChaosTest.enable_pod_failure(pod_name, self.__namespace)

    def disable_pod_failure(self, pod_name=None):
        if not pod_name:
            ExceptionHandler.raise_up(
                'Failed to disable pod failure, please provide the name of target pod'
            )

        LDB_ChaosTest.disable_pod_failure(pod_name, self.__namespace)
예제 #2
0
class _KernelChaos:
    def __init__(self, test_env=None):
        self.__env = test_env if test_env else "DEFAULT"

        self.__config = ConfigUtil(self.__env)
        self.__namespace = self.__config.get_pod_namespace()
        self.__linux = Shell(self.__config.get_main_server_ip(),
                             self.__config.get_authority_user(),
                             self.__config.get_authority_pwd())
        self.__log = Log.MyLog()

    pass
예제 #3
0
class _TimeChaos:
    def __init__(self, test_env=None):
        self.__env = test_env if test_env else "DEFAULT"

        self.__config = ConfigUtil(self.__env)
        self.__namespace = self.__config.get_pod_namespace()
        self.__linux = Shell(self.__config.get_main_server_ip(),
                             self.__config.get_authority_user(),
                             self.__config.get_authority_pwd())
        self.__log = Log.MyLog()

    def time_delay(self, pod_name, delay=''):
        if not pod_name:
            self.__log.error('error')
            return True

        self.__linux.execShell('')
예제 #4
0
class _NetworkChaos:
    def __init__(self, test_env=None):
        self.__env = test_env if test_env else "DEFAULT"
        self.__config = ConfigUtil(self.__env)
        self.__namespace = self.__config.get_pod_namespace()
        self.__linux = Shell(self.__config.get_main_server_ip(),
                             self.__config.get_authority_user(),
                             self.__config.get_authority_pwd())
        self.__log = Log.MyLog()

    def enable_network_split(self, node_group=None, target_node_group=None):
        if not node_group or not target_node_group:
            ExceptionHandler.raise_up(
                'Failed to enable network split, please provide the node group or target node group'
            )

        LDB_ChaosTest.enable_network_split(node_group, target_node_group,
                                           self.__namespace)

    def disable_network_split(self, node_group=None, target_node_group=None):
        if not node_group or not target_node_group:
            ExceptionHandler.raise_up(
                'Failed to disable network split, please provide the node group or target node group'
            )

        LDB_ChaosTest.disable_network_split(node_group, target_node_group,
                                            self.__namespace)

    def enable_network_delay(self, node_group=None):
        if not node_group:
            ExceptionHandler.raise_up(
                'Failed to enable network delay, please provide the node group'
            )

        LDB_ChaosTest.enable_network_delay(node_group, self.__namespace)

    def disable_network_delay(self, node_group=None):
        if not node_group:
            ExceptionHandler.raise_up(
                'Failed to disable network delay, please provide the node group'
            )

        LDB_ChaosTest.disable_network_delay(node_group, self.__namespace)
예제 #5
0
            #修改本地文件内容
            self.__localMachine.File.replace_line_with_new_str(
                os.path.join(self.__work_folder, file_name), key, new_str)

            #将远程机器上需要修改的文件替换为本地文件
            self.put_file_to_remote(local_file, remote_file)

            self.__log.info('替换文件{0}下包含关键字符{1}的行内容成功'.format(remote_file, key))
        except Exception as e:
            self.__log.error('替换文件{0}下包含关键字符{1}的行内容失败!异常信息:{2}'.format(
                remote_file, key, str(e)))
            raise RemoteHostException(
                '替换文件{0}下包含关键字符{1}的行内容失败!异常信息:{2}'.format(
                    remote_file, key, str(e)))


# RemoteFile -> end

if __name__ == "__main__":
    cmds = "pwd"
    config_info = ConfigUtil()
    #host_ips = config_info.get_host_ips().split(',')
    host_ips = config_info.get_main_server_ip()
    linux = Shell(config_info.get_main_server_ip(),
                  config_info.get_authority_user(),
                  config_info.get_authority_pwd())
    linux.execShell('pwd')
    # linux.kubectl.pod.get_meta_pallas_pods()
    # linux.kubectl.pod.get_pods()
    # linux.yarn.list_app()