当前位置: 首页>>代码示例>>Python>>正文


Python general.General类代码示例

本文整理汇总了Python中ci.tests.general.general.General的典型用法代码示例。如果您正苦于以下问题:Python General类的具体用法?Python General怎么用?Python General使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了General类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: config_files_check_test

    def config_files_check_test():
        """
        Verify some configuration files
        """
        issues_found = ''

        config_keys = {
            "/ovs/framework/memcache",
            "/ovs/arakoon/ovsdb/config"
        }

        for key_to_check in config_keys:
            if not Configuration.exists(key_to_check, raw=True):
                issues_found += "Couldn't find {0}\n".format(key_to_check)

        config_files = {
            "rabbitmq.config": "/etc/rabbitmq/rabbitmq.config",
        }
        grid_ip = General.get_config().get('main', 'grid_ip')
        ssh_pass = General.get_config().get('mgmtcenter', 'password')
        client = SSHClient(grid_ip, username='root', password=ssh_pass)
        for config_file_to_check in config_files.iterkeys():
            if not client.file_exists(config_files[config_file_to_check]):
                issues_found += "Couldn't find {0}\n".format(config_file_to_check)

        assert issues_found == '',\
            "Found the following issues while checking for the config files:{0}\n".format(issues_found)
开发者ID:openvstorage,项目名称:integrationtests,代码行数:27,代码来源:sanity_checks_test.py

示例2: system_services_check_test

    def system_services_check_test():
        """
        Verify some system services
        """
        services_to_commands = {
            "nginx": """ps -efx|grep nginx|grep -v grep""",
            "rabbitmq-server": """ps -ef|grep rabbitmq-|grep -v grep""",
            "memcached": """ps -ef|grep memcached|grep -v grep""",
            "ovs-arakoon-ovsdb": """initctl list| grep ovsdb""",
            "ovs-snmp": """initctl list| grep ovs-snmp""",
            "ovs-support-agent": """initctl list| grep support""",
            "ovs-volumerouter-consumer": """initctl list| grep volumerou""",
            "ovs-watcher-framework": """initctl list| grep watcher-fr"""
        }

        errors = ''
        services_checked = 'Following services found running:\n'
        grid_ip = General.get_config().get('main', 'grid_ip')
        ssh_pass = General.get_config().get('mgmtcenter', 'password')
        client = SSHClient(grid_ip, username='root', password=ssh_pass)

        for service_to_check in services_to_commands.iterkeys():
            out, err = client.run(services_to_commands[service_to_check], debug=True)
            if len(err):
                errors += "Error when trying to run {0}:\n{1}".format(services_to_commands[service_to_check], err)
            else:
                if len(out):
                    services_checked += "{0}\n".format(service_to_check)
                else:
                    errors += "Couldn't find {0} running process\n".format(service_to_check)

        print services_checked
        assert len(errors) == 0, "Found the following errors while checking for the system services:{0}\n".format(errors)
开发者ID:DarumasLegs,项目名称:integrationtests,代码行数:33,代码来源:sanity_checks_test.py

示例3: system_services_check_test

    def system_services_check_test():
        """
        Verify some system services
        """
        services_to_commands = {
            "nginx": """ps -efx|grep nginx|grep -v grep""",
            "rabbitmq-server": """ps -ef|grep rabbitmq-|grep -v grep""",
            "memcached": """ps -ef|grep memcached|grep -v grep""",
        }

        errors = ''
        services_checked = 'Following services found running:\n'
        grid_ip = General.get_config().get('main', 'grid_ip')
        ssh_pass = General.get_config().get('mgmtcenter', 'password')
        client = SSHClient(grid_ip, username='root', password=ssh_pass)

        for service_to_check in services_to_commands.iterkeys():
            out, err = client.run(services_to_commands[service_to_check], debug=True, allow_insecure=True,
                                  return_stderr=True)
            if len(err):
                errors += "Error when trying to run {0}:\n{1}".format(services_to_commands[service_to_check], err)
            else:
                if len(out):
                    services_checked += "{0}\n".format(service_to_check)
                else:
                    errors += "Couldn't find {0} running process\n".format(service_to_check)

        for non_running_service in GeneralSystem.list_non_running_ovs_services(grid_ip):
            errors += str(non_running_service)

        assert len(errors) == 0,\
            "Found the following errors while checking for the system services:{0}\n".format(errors)
开发者ID:openvstorage,项目名称:integrationtests,代码行数:32,代码来源:sanity_checks_test.py

示例4: remove_alba_namespaces

    def remove_alba_namespaces(alba_backend, namespaces=None):
        """
        Remove ALBA namespaces
        :param alba_backend: ALBA backend
        :param namespaces: Name of namespaces to remove
        :return: None
        """
        ns_to_delete = namespaces
        if namespaces is None:
            ns_to_delete = GeneralAlba.list_alba_namespaces(alba_backend=alba_backend)

        cmd_delete = "alba delete-namespace {0} ".format(GeneralAlba.get_abm_config(alba_backend))
        fd_namespaces = []
        for ns in ns_to_delete:
            namespace_name = str(ns['name'])
            if 'fd-' in namespace_name:
                fd_namespaces.append(ns)
                GeneralAlba.logger.info("Skipping vpool namespace: {0}".format(namespace_name))
                continue
            GeneralAlba.logger.info("WARNING: Deleting leftover namespace: {0}".format(str(ns)))
            GeneralAlba.logger.info(General.execute_command(cmd_delete + namespace_name)[0].replace('true', 'True'))

        if namespaces is None:
            for ns in fd_namespaces:
                GeneralAlba.logger.info("WARNING: Deleting leftover vpool namespace: {0}".format(str(ns)))
                GeneralAlba.logger.info(General.execute_command(cmd_delete + str(ns['name']))[0].replace('true', 'True'))
            assert len(fd_namespaces) == 0,\
                "Removing Alba namespaces should not be necessary!"
开发者ID:openvstorage,项目名称:integrationtests,代码行数:28,代码来源:general_alba.py

示例5: list_ovs_services

 def list_ovs_services(host=IP):
     if GeneralSystem.INIT_SYSTEM == "init":
         return General.execute_command_on_node(host, "initctl list | grep ovs-*", allow_insecure=True).splitlines()
     elif GeneralSystem.INIT_SYSTEM == "systemd":
         return General.execute_command_on_node(
             host, ["systemctl", "-l", "--no-legend", "--no-pager", "list-units", "ovs-*"]
         ).splitlines()
开发者ID:openvstorage,项目名称:integrationtests,代码行数:7,代码来源:general_system.py

示例6: setup

def setup():
    """
    Setup for DiskLayout package, will be executed when any test in this package is being executed
    Make necessary changes before being able to run the tests
    :return: None
    """
    General.validate_required_config_settings()
开发者ID:openvstorage,项目名称:integrationtests,代码行数:7,代码来源:__init__.py

示例7: unpartition_disk

    def unpartition_disk(disk, partitions=None, wait=True):
        """
        Return disk to RAW state
        :param disk: Disk DAL object
        :param partitions: Partitions DAL object list
        :return: None
        """
        if partitions is None:
            partitions = disk.partitions
        else:
            for partition in partitions:
                if partition not in disk.partitions:
                    raise RuntimeError('Partition {0} does not belong to disk {1}'.format(partition.mountpoint, disk.name))
        if len(disk.partitions) == 0:
            return

        root_client = SSHClient(disk.storagerouter, username='root')
        for partition in partitions:
            General.unmount_partition(root_client, partition)
        root_client.run(['parted', '-s', '/dev/' + disk.name, 'mklabel', 'gpt'])
        GeneralStorageRouter.sync_with_reality(disk.storagerouter)
        counter = 0
        timeout = 60
        while counter < timeout:
            time.sleep(1)
            disk = GeneralDisk.get_disk(guid=disk.guid)
            if len(disk.partitions) == 0:
                break
            counter += 1
        if counter == timeout:
            raise RuntimeError('Removing partitions failed for disk:\n {0} '.format(disk.name))
开发者ID:openvstorage,项目名称:integrationtests,代码行数:31,代码来源:general_disk.py

示例8: __init__

    def __init__(self, ip=None, username=None, password=None, verify=False):
        if ip is None:
            ip = General.get_config().get('main', 'grid_ip')
            assert ip, "Please specify a valid ip in autotests.cfg for grid_ip"
        if username is None:
            username = General.get_config().get('main', 'username')
            assert username, "Please specify a valid username in autotests.cfg"
        if password is None:
            password = General.get_config().get('main', 'password')
            assert password, "Please specify a valid password in autotests.cfg"

        self.ip = ip
        self.username = username
        self.password = password
        self.verify = verify

        self.headers = {'Accept': 'application/json; version=3'}
        if os.path.exists(self.TOKEN_CACHE_FILENAME) \
                and (time.time() - os.path.getmtime(self.TOKEN_CACHE_FILENAME) > 3600.0):
            os.remove(self.TOKEN_CACHE_FILENAME)
        if os.path.exists(self.TOKEN_CACHE_FILENAME):
            with open(self.TOKEN_CACHE_FILENAME, 'r') as token_cache_file:
                self.token = token_cache_file.read()
                self.headers['Authorization'] = 'Bearer {0}'.format(self.token)
        else:
            self.token = ''
            self.authenticate()

        if 'Authorization' not in self.headers.keys():
            self.authenticate()
开发者ID:openvstorage,项目名称:integrationtests,代码行数:30,代码来源:connection.py

示例9: setup

def setup():
    """
    Setup for System package, will be executed when any test in this package is being executed
    Make necessary changes before being able to run the tests
    :return: None
    """
    print "setup called " + __name__
    General.cleanup()
开发者ID:DarumasLegs,项目名称:integrationtests,代码行数:8,代码来源:__init__.py

示例10: get_unused_disks

    def get_unused_disks():
        """
        Retrieve all disks not in use
        :return: List of disks not being used
        """
        # @TODO: Make this call possible on all nodes, not only on node executing the tests
        all_disks = General.execute_command("""fdisk -l 2>/dev/null| awk '/Disk \/.*:/ {gsub(":","",$s);print $2}' | grep -v ram""")[0].splitlines()
        out = General.execute_command("df -h | awk '{print $1}'")[0]

        return [d for d in all_disks if d not in out and not 'mapper' in d and not General.execute_command("fuser {0}".format(d))[0]]
开发者ID:openvstorage,项目名称:integrationtests,代码行数:10,代码来源:general_disk.py

示例11: ovs_2493_detect_could_not_acquire_lock_events_test

    def ovs_2493_detect_could_not_acquire_lock_events_test():
        """
        Verify lock errors
        """
        errorlist = ""
        command = "grep -C 1 'Could not acquire lock' /var/log/ovs/lib.log"
        gridips = GeneralPMachine.get_all_ips()

        for gridip in gridips:
            out = General.execute_command_on_node(gridip, command + " | wc -l")
            if not out == '0':
                errorlist += "node %s \n:{0}\n\n".format(General.execute_command_on_node(gridip, command).splitlines()) % gridip

        assert len(errorlist) == 0, "Lock errors detected in lib logs on \n" + errorlist
开发者ID:DarumasLegs,项目名称:integrationtests,代码行数:14,代码来源:validation_after_test.py

示例12: teardown

def teardown():
    """
    Teardown for VirtualMachine package, will be executed when all started tests in this package have ended
    Removal actions of possible things left over after the test-run
    :return: None
    """
    vpool_name = General.get_config().get('vpool', 'name')
    vpool = GeneralVPool.get_vpool_by_name(vpool_name)
    assert vpool is not None, "No vpool found where one was expected"
    GeneralVMachine.logger.info("Cleaning vpool")
    GeneralVPool.remove_vpool(vpool)

    alba_backend = GeneralAlba.get_by_name(General.get_config().get('backend', 'name'))
    if alba_backend is not None:
        GeneralAlba.unclaim_disks_and_remove_alba_backend(alba_backend=alba_backend)
开发者ID:openvstorage,项目名称:integrationtests,代码行数:15,代码来源:__init__.py

示例13: load_path

 def load_path(source):
     """
     Retrieve the absolute path for the logfile
     :param source: Source for the logfile
     :return: Absolute path to logfile
     """
     log_path = General.get_config().get('logger', 'path')
     if not os.path.exists(log_path):
         os.mkdir(log_path)
     file_name = LogHandler.targets[source] if source in LogHandler.targets else General.get_config().get('logger', 'default_file')
     log_filename = '{0}/{1}.log'.format(log_path, file_name)
     if not os.path.exists(log_filename):
         open(log_filename, 'a').close()
         os.chmod(log_filename, 0o666)
     return log_filename
开发者ID:openvstorage,项目名称:integrationtests,代码行数:15,代码来源:logHandler.py

示例14: get_hypervisor_type

 def get_hypervisor_type():
     """
     Retrieve type of hypervisor
     :return hypervisor type ['KVM'|'VMWARE']
     """
     config = General.get_config()
     return config.get('hypervisor', 'type')
开发者ID:openvstorage,项目名称:integrationtests,代码行数:7,代码来源:general_hypervisor.py

示例15: post_reboot_checks_test

    def post_reboot_checks_test():
        """
        Perform service checks after reboot
        """
        rebooted_host = os.environ.get('POST_REBOOT_HOST')
        if not rebooted_host:
            logger.info('Test not setup to run')
            return

        logger.info('Post reboot check node {0}\n'.format(rebooted_host))

        wait_time = 5 * 60
        sleep_time = 5

        non_running_services = ''
        while wait_time > 0:
            out = General.execute_command_on_node(rebooted_host, "initctl list | grep ovs-*")
            statuses = out.splitlines()

            non_running_services = [s for s in statuses if 'start/running' not in s]
            if len(non_running_services) == 0:
                break

            wait_time -= sleep_time
            time.sleep(sleep_time)

        assert len(non_running_services) == 0,\
            "Found non running services after reboot on node {0}\n{1}".format(rebooted_host, non_running_services)
开发者ID:DarumasLegs,项目名称:integrationtests,代码行数:28,代码来源:extended_test.py


注:本文中的ci.tests.general.general.General类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。