Exemple #1
0
    def create(self, name, fromenv=False, filename=None, do_use=False):
        """Create new deployment.

        This command will create a new deployment record in rally
        database. In the case of ExistingCloud deployment engine it
        will use the cloud represented in the configuration. If the
        cloud doesn't exist, Rally can deploy a new one for you with
        Devstack or Fuel. Different deployment engines exist for these
        cases.

        If you use the ExistingCloud deployment engine you can pass
        a deployment config by environment variables with ``--fromenv``:

            OS_USERNAME
            OS_PASSWORD
            OS_AUTH_URL
            OS_TENANT_NAME
            OS_ENDPOINT_TYPE or OS_INTERFACE
            OS_ENDPOINT
            OS_REGION_NAME
            OS_CACERT
            OS_INSECURE

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

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

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

        if fromenv:
            config = {"type": "ExistingCloud"}
            config.update(envutils.get_creds_from_env_vars())
        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:
            self.use(deployment["uuid"])
Exemple #2
0
    def create(self, name, fromenv=False, filename=None, do_use=False):
        """Create new deployment.

        This command will create a new deployment record in rally
        database. In the case of ExistingCloud deployment engine it
        will use the cloud represented in the configuration. If the
        cloud doesn't exist, Rally can deploy a new one for you with
        Devstack or Fuel. Different deployment engines exist for these
        cases.

        If you use the ExistingCloud deployment engine you can pass
        a deployment config by environment variables with ``--fromenv``:

            OS_USERNAME
            OS_PASSWORD
            OS_AUTH_URL
            OS_TENANT_NAME
            OS_ENDPOINT_TYPE or OS_INTERFACE
            OS_ENDPOINT
            OS_REGION_NAME
            OS_CACERT
            OS_INSECURE

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

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

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

        if fromenv:
            config = {"type": "ExistingCloud"}
            config.update(envutils.get_creds_from_env_vars())
        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:
            self.use(deployment["uuid"])
Exemple #3
0
    def create(self, api, name, fromenv=False, filename=None, do_use=False):
        """Create new deployment.

        This command will create a new deployment record in rally
        database. In the case of ExistingCloud deployment engine, it
        will use the cloud represented in the configuration. If the
        cloud doesn't exist, Rally can deploy a new one for you with
        Devstack or Fuel. Different deployment engines exist for these
        cases (see `rally plugin list --plugin-base Engine` for
        more details).

        If you use the ExistingCloud deployment engine, you can pass
        the deployment config by environment variables with ``--fromenv``:

            OS_USERNAME
            OS_PASSWORD
            OS_AUTH_URL
            OS_TENANT_NAME or OS_PROJECT_NAME
            OS_ENDPOINT_TYPE or OS_INTERFACE
            OS_ENDPOINT
            OS_REGION_NAME
            OS_CACERT
            OS_INSECURE
            OS_IDENTITY_API_VERSION

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

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

        if fromenv:
            # TODO(astudenov): move this to Credential plugin
            config = {
                "type": "ExistingCloud",
                "creds": {"openstack": envutils.get_creds_from_env_vars()}}
        else:
            if not filename:
                config = {}
            else:
                with open(os.path.expanduser(filename), "rb") as deploy_file:
                    config = yaml.safe_load(deploy_file.read())

        try:
            deployment = api.deployment.create(config=config, name=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(api, deployment_list=[deployment])
        if do_use:
            self.use(api, deployment)
Exemple #4
0
    def create(self, api, name, fromenv=False, filename=None, do_use=False):
        """Create new deployment.

        This command will create a new deployment record in rally
        database. In the case of ExistingCloud deployment engine, it
        will use the cloud represented in the configuration. If the
        cloud doesn't exist, Rally can deploy a new one for you with
        Devstack or Fuel. Different deployment engines exist for these
        cases (see `rally plugin list --plugin-base Engine` for
        more details).

        If you use the ExistingCloud deployment engine, you can pass
        the deployment config by environment variables with ``--fromenv``:

            OS_USERNAME
            OS_PASSWORD
            OS_AUTH_URL
            OS_TENANT_NAME or OS_PROJECT_NAME
            OS_ENDPOINT_TYPE or OS_INTERFACE
            OS_ENDPOINT
            OS_REGION_NAME
            OS_CACERT
            OS_INSECURE
            OS_IDENTITY_API_VERSION

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

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

        if fromenv:
            # TODO(astudenov): move this to Credential plugin
            config = {"openstack": envutils.get_creds_from_env_vars()}
        else:
            if not filename:
                config = {}
            else:
                with open(os.path.expanduser(filename), "rb") as deploy_file:
                    config = yaml.safe_load(deploy_file.read())

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

        self.list(api, deployment_list=[deployment])
        if do_use:
            self.use(api, deployment)
Exemple #5
0
 def create_from_env(cls):
     creds = envutils.get_creds_from_env_vars()
     return cls(
         objects.Credential(creds["auth_url"],
                            creds["admin"]["username"],
                            creds["admin"]["password"],
                            creds["admin"]["tenant_name"],
                            endpoint=creds["endpoint"],
                            region_name=creds["region_name"],
                            https_cacert=creds["https_cacert"],
                            https_insecure=creds["https_insecure"]))
Exemple #6
0
 def create_from_env(cls):
     creds = envutils.get_creds_from_env_vars()
     return cls(
         objects.Credential(
             creds["auth_url"],
             creds["admin"]["username"],
             creds["admin"]["password"],
             creds["admin"]["tenant_name"],
             endpoint=creds["endpoint"],
             region_name=creds["region_name"],
             https_cacert=creds["https_cacert"],
             https_insecure=creds["https_insecure"]
         ))
Exemple #7
0
 def test_get_creds_from_env_vars(self):
     expected_creds = {
         "auth_url": "fake_auth_url",
         "admin": {
             "username": "******",
             "password": "******",
             "tenant_name": "fake_tenant_name"
         },
         "endpoint": "fake_endpoint",
         "region_name": "fake_region_name",
         "https_cacert": "fake_cacert",
         "https_insecure": True
     }
     creds = envutils.get_creds_from_env_vars()
     self.assertEqual(expected_creds, creds)
Exemple #8
0
 def test_get_creds_from_env_vars(self):
     expected_creds = {
         "auth_url": "fake_auth_url",
         "admin": {
             "username": "******",
             "password": "******",
             "tenant_name": "fake_tenant_name"
         },
         "endpoint": "fake_endpoint",
         "region_name": "fake_region_name",
         "https_cacert": "fake_cacert",
         "https_insecure": True
     }
     creds = envutils.get_creds_from_env_vars()
     self.assertEqual(expected_creds, creds)
Exemple #9
0
 def create_from_env(cls):
     creds = envutils.get_creds_from_env_vars()
     from rally.plugins.openstack import credential
     oscred = credential.OpenStackCredential(
         auth_url=creds["auth_url"],
         username=creds["admin"]["username"],
         password=creds["admin"]["password"],
         tenant_name=creds["admin"]["tenant_name"],
         endpoint_type=creds["endpoint_type"],
         user_domain_name=creds["admin"].get("user_domain_name"),
         project_domain_name=creds["admin"].get("project_domain_name"),
         endpoint=creds["endpoint"],
         region_name=creds["region_name"],
         https_cacert=creds["https_cacert"],
         https_insecure=creds["https_insecure"])
     return cls(oscred)
Exemple #10
0
 def test_get_creds_from_env_vars_keystone_v2(self):
     expected_creds = {
         "auth_url": "fake_auth_url",
         "admin": {
             "username": "******",
             "password": "******",
             "tenant_name": "fake_tenant_name"
         },
         "endpoint_type": "fake_endpoint_type",
         "endpoint": "fake_endpoint",
         "region_name": "fake_region_name",
         "https_cacert": "fake_cacert",
         "https_insecure": True,
         "profiler_hmac_key": "fake_hmac_key",
         "profiler_conn_str": "fake_conn_str"
     }
     creds = envutils.get_creds_from_env_vars()
     self.assertEqual(expected_creds, creds)