Exemplo n.º 1
0
    def start(self, task, deploy_id=None, tag=None, do_use=False):
        """Start benchmark task.

        :param task: a file with yaml/json configration
        :param deploy_id: a UUID of a deployment
        :param tag: optional tag for this task
        """
        task = os.path.expanduser(task)
        with open(task, 'rb') as task_file:
            config_dict = yaml.safe_load(task_file.read())
            try:
                task = api.create_task(deploy_id, tag)
                print("=" * 80)
                print(
                    _("Task %(tag)s %(uuid)s is started") % {
                        "uuid": task["uuid"],
                        "tag": task["tag"]
                    })
                print("-" * 80)
                api.start_task(deploy_id, config_dict, task=task)
                self.detailed(task_id=task['uuid'])
                if do_use:
                    use.UseCommands().task(task['uuid'])
            except exceptions.InvalidConfigException:
                return (1)
            except KeyboardInterrupt:
                api.abort_task(task['uuid'])
                raise
Exemplo n.º 2
0
    def start(self,
              set_name="",
              deployment=None,
              regex=None,
              tempest_config=None,
              do_use=False):
        """Start set of tests.

        :param set_name: Name of tempest test set
        :param deployment: UUID or name of a deployment
        :param regex: Regular expression of test
        :param tempest_config: User specified Tempest config file location
        """

        if regex and set_name:
            raise exceptions.InvalidArgumentsException("set_name and regex "
                                                       "are not compatible")
        if not (regex or set_name):
            set_name = "full"
        if set_name and set_name not in (list(consts.TempestTestsSets) +
                                         list(consts.TempestTestsAPI)):
            print("Sorry, but there are no desired tempest test set. Please "
                  "choose from: %s" % ", ".join(
                      list(consts.TempestTestsSets) +
                      list(consts.TempestTestsAPI)))
            return (1)
        verification = api.Verification.verify(deployment, set_name, regex,
                                               tempest_config)
        if do_use:
            use.UseCommands().verification(verification["uuid"])
Exemplo n.º 3
0
    def start(self,
              task,
              deployment=None,
              task_args=None,
              task_args_file=None,
              tag=None,
              do_use=False,
              abort_on_sla_failure=False):
        """Start benchmark task.

        :param task: a file with yaml/json task
        :param task_args: Input task args (dict in json/yaml). These args are
                          used to render input task that is jinja2 template.
        :param task_args_file: File with input task args (dict in json/yaml).
                               These args are used to render input task that
                               is jinja2 template.
        :param deployment: UUID or name of a deployment
        :param tag: optional tag for this task
        :param do_use: if True, the new task will be stored as the default one
                       for future operations
        :param abort_on_sla_failure: if True, the execution of a benchmark
                                     scenario will stop when any SLA check
                                     for it fails
        """
        try:
            input_task = self._load_task(task, task_args, task_args_file)
        except FailedToLoadTask:
            return (1)

        try:
            task = api.Task.create(deployment, tag)
            print(
                cliutils.make_header(
                    _("Task %(tag)s %(uuid)s: started") % {
                        "uuid": task["uuid"],
                        "tag": task["tag"]
                    }))
            print("Benchmarking... This can take a while...\n")
            print("To track task status use:\n")
            print("\trally task status\n\tor\n\trally task detailed\n")
            api.Task.start(deployment,
                           input_task,
                           task=task,
                           abort_on_sla_failure=abort_on_sla_failure)
            self.detailed(task_id=task["uuid"])
            if do_use:
                use.UseCommands().task(task["uuid"])
        except exceptions.InvalidConfigException:
            return (1)
Exemplo n.º 4
0
    def create(self, name, fromenv=False, filename=None, do_use=False):
        """Create a new deployment on the basis of configuration file.

        :param fromenv: boolean, read environment instead of config file
        :param filename: a path to the configuration file
        :param name: a name of the deployment
        """

        if fromenv:
            required_env_vars = [
                "OS_USERNAME", "OS_PASSWORD", "OS_AUTH_URL", "OS_TENANT_NAME"
            ]

            unavailable_vars = [
                v for v in required_env_vars if v not in os.environ
            ]
            if unavailable_vars:
                print("The following environment variables are required but "
                      "not set: %s" % ' '.join(unavailable_vars))
                return (1)

            config = {
                "type": "ExistingCloud",
                "endpoint": {
                    "auth_url": os.environ['OS_AUTH_URL'],
                    "username": os.environ['OS_USERNAME'],
                    "password": os.environ['OS_PASSWORD'],
                    "tenant_name": os.environ['OS_TENANT_NAME']
                }
            }
            region_name = os.environ.get('OS_REGION_NAME')
            if region_name and region_name != 'None':
                config['endpoint']['region_name'] = region_name
        else:
            if not filename:
                print("Either --filename or --fromenv is required")
                return (1)
            with open(filename, 'rb') as deploy_file:
                config = yaml.safe_load(deploy_file.read())

        deployment = api.create_deploy(config, name)
        self.list(deployment_list=[deployment])
        if do_use:
            use.UseCommands().deployment(deployment['uuid'])
Exemplo n.º 5
0
    def start(self,
              set_name="smoke",
              deploy_id=None,
              regex=None,
              tempest_config=None,
              do_use=False):
        """Start set of tests.

        :param set_name: Name of tempest test set
        :param deploy_id: a UUID of a deployment
        :param regex: Regular expression of test
        :param tempest_config: User specified Tempest config file location
        """

        if regex:
            set_name = "full"
        if set_name not in consts.TEMPEST_TEST_SETS:
            print("Sorry, but there are no desired tempest test set. Please "
                  "choose from: %s" % ", ".join(consts.TEMPEST_TEST_SETS))
            return (1)
        verification = api.verify(deploy_id, set_name, regex, tempest_config)
        if do_use:
            use.UseCommands().verification(verification["uuid"])
Exemplo n.º 6
0
 def setUp(self):
     super(UseCommandsTestCase, self).setUp()
     self.use = use.UseCommands()
Exemplo n.º 7
0
    def create(self, name, fromenv=False, filename=None, do_use=False):
        """Create new deployment.

        This command will create new deployment record in rally database.
        In case of ExistingCloud deployment engine it will use cloud,
        represented in config.
        In cases when cloud doesn't exists Rally will deploy new one
        for you with Devstack or Fuel. For this purposes different deployment
        engines are developed.

        If you use ExistionCloud deployment engine you can pass deployment
        config by environment variables:
            OS_USERNAME
            OS_PASSWORD
            OS_AUTH_URL
            OS_TENANT_NAME

        All other deployment engines need more complex configuration data, so
        it should be stored in configuration file.

        You can use physical servers, lxc containers, KVM virtual machines
        or virtual machines in OpenStack for deploying the cloud in.
        Except physical servers, Rally can create cluster nodes for you.
        Interaction with virtualisation software, OpenStack
        cloud or physical servers is provided by server providers.

        :param fromenv: boolean, read environment instead of config file
        :param filename: a path to the configuration file
        :param name: a name of the deployment
        """

        if fromenv:
            required_env_vars = [
                "OS_USERNAME", "OS_PASSWORD", "OS_AUTH_URL", "OS_TENANT_NAME"
            ]

            unavailable_vars = [
                v for v in required_env_vars if v not in os.environ
            ]
            if unavailable_vars:
                print("The following environment variables are required but "
                      "not set: %s" % " ".join(unavailable_vars))
                return (1)

            config = {
                "type": "ExistingCloud",
                "auth_url": os.environ["OS_AUTH_URL"],
                "admin": {
                    "username": os.environ["OS_USERNAME"],
                    "password": os.environ["OS_PASSWORD"],
                    "tenant_name": os.environ["OS_TENANT_NAME"]
                }
            }
            region_name = os.environ.get("OS_REGION_NAME")
            if region_name and region_name != "None":
                config["region_name"] = region_name
        else:
            if not filename:
                print("Either --filename or --fromenv is required")
                return (1)
            filename = os.path.expanduser(filename)
            with open(filename, "rb") as deploy_file:
                config = yaml.safe_load(deploy_file.read())

        try:
            deployment = api.Deployment.create(config, name)
        except jsonschema.ValidationError:
            print(_("Config schema validation error: %s.") % sys.exc_info()[1])
            return (1)
        except exceptions.DeploymentNameExists:
            print(_("Error: %s") % sys.exc_info()[1])
            return (1)

        self.list(deployment_list=[deployment])
        if do_use:
            use.UseCommands().deployment(deployment["uuid"])
Exemplo n.º 8
0
    def use(self, deployment):
        """Set active deployment. Alias for "rally use deployment".

        :param deployment: UUID or name of a deployment
        """
        use.UseCommands().deployment(deployment)
Exemplo n.º 9
0
    def use(self, task):
        """Set active task. Alias for "rally use task".

        :param task: Task uuid.
        """
        use.UseCommands().task(task)
Exemplo n.º 10
0
    def use(self, verification):
        """Set active verification. Alias for "rally use verification"

        :param verification: a UUID of verification
        """
        use.UseCommands().verification(verification)