Пример #1
0
 def _get_scenario_group_info(self, query):
     try:
         scenario_group = scenario_base.Scenario.get_by_name(query)
         info = ("%s (benchmark scenario group).\n\n" %
                 scenario_group.__name__)
         info += utils.format_docstring(scenario_group.__doc__)
         info += "\nBenchmark scenarios:\n"
         scenarios = scenario_group.list_benchmark_scenarios()
         first_column_len = max(map(len, scenarios)) + cliutils.MARGIN
         second_column_len = len("Description") + cliutils.MARGIN
         table = ""
         for scenario_name in scenarios:
             cls, method_name = scenario_name.split(".")
             if hasattr(scenario_group, method_name):
                 scenario = getattr(scenario_group, method_name)
                 doc = utils.parse_docstring(scenario.__doc__)
                 descr = doc["short_description"] or ""
                 second_column_len = max(second_column_len,
                                         len(descr) + cliutils.MARGIN)
                 table += " " + scenario_name
                 table += " " * (first_column_len - len(scenario_name))
                 table += descr + "\n"
         info += "-" * (first_column_len + second_column_len + 1) + "\n"
         info += (" Name" + " " * (first_column_len - len("Name")) +
                  "Description\n")
         info += "-" * (first_column_len + second_column_len + 1) + "\n"
         info += table
         return info
     except exceptions.NoSuchScenario:
         return None
Пример #2
0
    def find(self, query):
        """Search for an entity that matches the query and print info about it.

        :param query: search query.
        """
        scenario_group = searchutils.find_benchmark_scenario_group(query)
        if scenario_group:
            print("%s (benchmark scenario group).\n" % scenario_group.__name__)
            # TODO(msdubov): Provide all scenario classes with docstrings.
            doc = utils.format_docstring(scenario_group.__doc__)
            print(doc)
            return

        scenario = searchutils.find_benchmark_scenario(query)
        if scenario:
            print("%(scenario_group)s.%(scenario_name)s "
                  "(benchmark scenario).\n" %
                  {"scenario_group": utils.get_method_class(scenario).__name__,
                   "scenario_name": scenario.__name__})
            doc = utils.parse_docstring(scenario.__doc__)
            print(doc["short_description"] + "\n")
            if doc["long_description"]:
                print(doc["long_description"] + "\n")
            if doc["params"]:
                print("Parameters:")
                for param in doc["params"]:
                    print("    - %(name)s: %(doc)s" % param)
            if doc["returns"]:
                print("Returns: %s" % doc["returns"])
            return

        print("Failed to find any docs for query: '%s'" % query)
        return 1
Пример #3
0
 def _get_scenario_group_info(self, query):
     try:
         scenario_group = scenario_base.Scenario.get_by_name(query)
         info = ("%s (benchmark scenario group).\n\n" %
                 scenario_group.__name__)
         info += utils.format_docstring(scenario_group.__doc__)
         info += "\nBenchmark scenarios:\n"
         scenarios = scenario_group.list_benchmark_scenarios()
         first_column_len = max(map(len, scenarios)) + cliutils.MARGIN
         second_column_len = len("Description") + cliutils.MARGIN
         table = ""
         for scenario_name in scenarios:
             cls, method_name = scenario_name.split(".")
             if hasattr(scenario_group, method_name):
                 scenario = getattr(scenario_group, method_name)
                 doc = utils.parse_docstring(scenario.__doc__)
                 descr = doc["short_description"] or ""
                 second_column_len = max(second_column_len,
                                         len(descr) + cliutils.MARGIN)
                 table += " " + scenario_name
                 table += " " * (first_column_len - len(scenario_name))
                 table += descr + "\n"
         info += "-" * (first_column_len + second_column_len + 1) + "\n"
         info += (" Name" + " " * (first_column_len - len("Name")) +
                  "Description\n")
         info += "-" * (first_column_len + second_column_len + 1) + "\n"
         info += table
         return info
     except exceptions.NoSuchScenario:
         return None
Пример #4
0
 def _get_server_provider_info(self, query):
     try:
         server_provider = serverprovider.ProviderFactory.get_by_name(query)
         info = "%s (server provider).\n\n" % server_provider.__name__
         info += utils.format_docstring(server_provider.__doc__)
         return info
     except exceptions.NoSuchVMProvider:
         return None
Пример #5
0
 def _get_deploy_engine_info(self, query):
     try:
         deploy_engine = deploy.EngineFactory.get_by_name(query)
         info = "%s (deploy engine).\n\n" % deploy_engine.__name__
         info += utils.format_docstring(deploy_engine.__doc__)
         return info
     except exceptions.NoSuchEngine:
         return None
Пример #6
0
 def _get_sla_info(self, query):
     try:
         sla = sla_base.SLA.get_by_name(query)
         info = "%s (SLA).\n\n" % sla.__name__
         info += utils.format_docstring(sla.__doc__)
         return info
     except exceptions.NoSuchSLA:
         return None
Пример #7
0
 def _get_server_provider_info(self, query):
     try:
         server_provider = serverprovider.ProviderFactory.get_by_name(query)
         info = "%s (server provider).\n\n" % server_provider.__name__
         info += utils.format_docstring(server_provider.__doc__)
         return info
     except exceptions.NoSuchVMProvider:
         return None
Пример #8
0
 def _get_deploy_engine_info(self, query):
     try:
         deploy_engine = deploy.EngineFactory.get_by_name(query)
         info = "%s (deploy engine).\n\n" % deploy_engine.__name__
         info += utils.format_docstring(deploy_engine.__doc__)
         return info
     except exceptions.NoSuchEngine:
         return None
Пример #9
0
 def _get_sla_info(self, query):
     try:
         sla = sla_base.SLA.get_by_name(query)
         info = "%s (SLA).\n\n" % sla.__name__
         info += utils.format_docstring(sla.__doc__)
         return info
     except exceptions.NoSuchSLA:
         return None
Пример #10
0
 def _get_scenario_group_info(self, query):
     try:
         scenario_group = scenario_base.Scenario.get_by_name(query)
         info = ("%s (benchmark scenario group).\n\n" %
                 scenario_group.__name__)
         info += utils.format_docstring(scenario_group.__doc__)
         return info
     except exceptions.NoSuchScenario:
         return None
Пример #11
0
 def _get_sla_info(self, query):
     try:
         sla = sla_base.SLA.get_by_name(query)
         header = "%s (SLA)" % sla.OPTION_NAME
         info = self._make_header(header)
         info += "\n\n"
         info += utils.format_docstring(sla.__doc__) + "\n"
         return info
     except exceptions.NoSuchSLA:
         return None
Пример #12
0
 def _get_scenario_group_info(self, query):
     try:
         scenario_group = scenario_base.Scenario.get_by_name(query)
         if not any(scenario_base.Scenario.is_scenario(scenario_group, m)
                    for m in dir(scenario_group)):
             return None
         info = self._make_header("%s (benchmark scenario group)" %
                                  scenario_group.__name__)
         info += "\n\n"
         info += utils.format_docstring(scenario_group.__doc__)
         scenarios = scenario_group.list_benchmark_scenarios()
         descriptions = []
         for scenario_name in scenarios:
             cls, method_name = scenario_name.split(".")
             if hasattr(scenario_group, method_name):
                 scenario = getattr(scenario_group, method_name)
                 doc = utils.parse_docstring(scenario.__doc__)
                 descr = doc["short_description"] or ""
                 descriptions.append((scenario_name, descr))
         info += self._compose_table("Benchmark scenarios", descriptions)
         return info
     except exceptions.NoSuchScenario:
         return None