Exemplo n.º 1
0
    def create(self, filename, name):
        """Create a new deployment on the basis of configuration file.

        :param filename: a path to the configuration file
        :param name: a name of the deployment
        """
        with open(filename) as f:
            config = json.load(f)
            api.create_deploy(config, name)
Exemplo n.º 2
0
 def test_create_deploy(self, mock_create, mock_update):
     mock_create.return_value = self.deployment
     mock_update.return_value = self.deployment
     api.create_deploy(self.deploy_config, 'fake_deploy')
     mock_create.assert_called_once_with({
         'name': 'fake_deploy',
         'config': self.deploy_config,
     })
     mock_update.assert_has_calls(
         [mock.call(self.deploy_uuid, {'endpoints': self.endpoints})])
Exemplo n.º 3
0
 def test_create_deploy(self, mock_create, mock_update):
     mock_create.return_value = self.deployment
     mock_update.return_value = self.deployment
     api.create_deploy(self.deploy_config, 'fake_deploy')
     mock_create.assert_called_once_with({
         'name': 'fake_deploy',
         'config': self.deploy_config,
     })
     mock_update.assert_has_calls([
         mock.call(self.deploy_uuid, {'endpoints': self.endpoints})
     ])
Exemplo n.º 4
0
 def test_create_deploy(self, mock_validate, mock_create, mock_update):
     mock_create.return_value = self.deployment
     mock_update.return_value = self.deployment
     api.create_deploy(self.deploy_config, "fake_deploy")
     mock_create.assert_called_once_with({
         "name": "fake_deploy",
         "config": self.deploy_config,
     })
     mock_validate.assert_called_with()
     mock_update.assert_has_calls(
         [mock.call(self.deploy_uuid, self.endpoints)])
Exemplo n.º 5
0
 def test_create_deploy(self, mock_create, mock_update):
     mock_create.return_value = self.deployment
     mock_update.return_value = self.deployment
     api.create_deploy(self.deploy_config, "fake_deploy")
     mock_create.assert_called_once_with({
         "name": "fake_deploy",
         "config": self.deploy_config,
     })
     mock_update.assert_has_calls([
         mock.call(self.deploy_uuid, self.endpoints)
     ])
Exemplo n.º 6
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",
                "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.create_deploy(config, name)
        except jsonschema.ValidationError:
            print(_("Config schema validation error: %s.") % sys.exc_info()[1])
            return(1)

        self.list(deployment_list=[deployment])
        if do_use:
            use.UseCommands().deployment(deployment['uuid'])
Exemplo n.º 7
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.º 8
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

            config = {
                "name": "DummyEngine",
                "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']
                }
            }
        else:
            if not filename:
                print("Either --filename or --fromenv is required")
                return
            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.º 9
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.create_deploy(config, name)
        except jsonschema.ValidationError:
            print(_("Config schema validation error: %s.") % sys.exc_info()[1])
            return (1)

        self.list(deployment_list=[deployment])
        if do_use:
            use.UseCommands().deployment(deployment['uuid'])
Exemplo n.º 10
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.create_deploy(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'])