Replace DeploymentEngine with EnvManager

It is impossible to replace the whole deployment component at once. At
least because we need to make it backward compatible.
This patch starts this effort.

What is done:
- the database layer is cleaned from deployments and resources tables.
  the api of database layer is also cleaned from deployment related
  things
  PS: all the current deploment records move to the env and platforms
      tables
- rally.common.objects.Deployment became a proxy layer between old world
  and new one (Environment component). It provides the full
  compatibility in terms of data and interfaces
- rally.api.API.deployment starts using some new interfaces of
  EnvManager directly, where it is possible
- DeploymentEngine (with "ExistingCloud" plugin), CredentialsBuilder
  (with "openstack" plugin) are deleted.
  It should be noted in release notes...
- EnvManager starts cleaning verifier specific data as well..

Change-Id: If7bde619f7c2e99248a071ff18b8084553e1bec0
This commit is contained in:
Andrey Kurilin 2018-01-12 19:06:29 +02:00
parent 4af4ccd241
commit 52b2a7bd5e
4 changed files with 1 additions and 201 deletions

View File

@ -100,105 +100,3 @@ class OpenStackCredential(credential.Credential):
def clients(self, api_info=None):
return osclients.Clients(self, api_info=api_info,
cache=self._clients_cache)
@credential.configure_builder("openstack")
class OpenStackCredentialBuilder(credential.CredentialBuilder):
"""Builds credentials provided by ExistingCloud config."""
USER_SCHEMA = {
"type": "object",
"oneOf": [
{
"description": "Keystone V2.0",
"properties": {
"username": {"type": "string"},
"password": {"type": "string"},
"tenant_name": {"type": "string"},
},
"required": ["username", "password", "tenant_name"],
"additionalProperties": False
},
{
"description": "Keystone V3.0",
"properties": {
"username": {"type": "string"},
"password": {"type": "string"},
"domain_name": {"type": "string"},
"user_domain_name": {"type": "string"},
"project_name": {"type": "string"},
"project_domain_name": {"type": "string"},
},
"required": ["username", "password", "project_name"],
"additionalProperties": False
}
],
}
CONFIG_SCHEMA = {
"type": "object",
"properties": {
"admin": USER_SCHEMA,
"users": {"type": "array", "items": USER_SCHEMA, "minItems": 1},
"auth_url": {"type": "string"},
"region_name": {"type": "string"},
# NOTE(andreykurilin): it looks like we do not use endpoint
# var at all
"endpoint": {"type": ["string", "null"]},
"endpoint_type": {
"enum": [consts.EndpointType.ADMIN,
consts.EndpointType.INTERNAL,
consts.EndpointType.PUBLIC,
None]},
"https_insecure": {"type": "boolean"},
"https_cacert": {"type": "string"},
"profiler_hmac_key": {"type": ["string", "null"]},
"profiler_conn_str": {"type": ["string", "null"]}
},
"anyOf": [
{"description": "The case when the admin is specified and the "
"users can be created via 'users' context or "
"'existing_users' will be used.",
"required": ["auth_url", "admin"]},
{"description": "The case when the only existing users are "
"specified.",
"required": ["auth_url", "users"]}
],
"additionalProperties": False
}
def _create_credential(self, common, user, permission):
cred = OpenStackCredential(
auth_url=common["auth_url"],
username=user["username"],
password=user["password"],
tenant_name=user.get("project_name", user.get("tenant_name")),
permission=permission,
region_name=common.get("region_name"),
endpoint_type=common.get("endpoint_type"),
endpoint=common.get("endpoint"),
domain_name=user.get("domain_name"),
user_domain_name=user.get("user_domain_name", None),
project_domain_name=user.get("project_domain_name", None),
https_insecure=common.get("https_insecure", False),
https_cacert=common.get("https_cacert"),
profiler_hmac_key=common.get("profiler_hmac_key"),
profiler_conn_str=common.get("profiler_conn_str"))
return cred.to_dict()
def build_credentials(self):
permissions = consts.EndpointPermission
users = [self._create_credential(self.config, user, permissions.USER)
for user in self.config.get("users", [])]
admin = None
if self.config.get("admin"):
admin = self._create_credential(self.config,
self.config.get("admin"),
permissions.ADMIN)
return {"admin": admin, "users": users}
# NOTE(astudenov): Let's consider moving rally.osclients here

View File

@ -70,7 +70,7 @@ class TestTaskSamples(unittest.TestCase):
user_ctx.setup()
self.addCleanup(user_ctx.cleanup)
os_creds = deployment["config"]["creds"]["openstack"]
os_creds = deployment["config"]["openstack"]
user = copy.copy(os_creds["admin"])
user["username"] = ctx["users"][0]["credential"].username

View File

@ -109,27 +109,6 @@ class DeploymentTestCase(unittest.TestCase):
self.fail("rally deployment fails to raise error for wrong"
" authentication info")
def test_recreate(self):
rally = utils.Rally()
rally.env.update(TEST_ENV)
rally("deployment create --name t_create_env --fromenv")
rally("deployment recreate --deployment t_create_env")
self.assertIn("t_create_env", rally("deployment list"))
def test_recreate_from_file(self):
rally = utils.Rally()
rally.env.update(TEST_ENV)
rally("deployment create --name t_create_env --fromenv")
config = json.loads(rally("deployment config"))
config["openstack"]["auth_url"] = "http://foo/"
file = utils.JsonTempFile(config)
rally("deployment recreate --deployment t_create_env "
"--filename %s" % file.filename)
self.assertIn("t_create_env", rally("deployment list"))
self.assertEqual(config,
json.loads(rally("deployment config")))
self.assertIn("http://foo/", rally("deployment show"))
def test_use(self):
rally = utils.Rally()
rally.env.update(TEST_ENV)

View File

@ -13,7 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import jsonschema
import mock
from rally import consts
@ -81,79 +80,3 @@ class OpenStackCredentialTestCase(test.TestCase):
mock_clients.assert_called_once_with(
self.credential, api_info="fake_info", cache={})
self.assertIs(mock_clients.return_value, clients)
class OpenStackCredentialBuilderTestCase(test.TestCase):
def setUp(self):
super(OpenStackCredentialBuilderTestCase, self).setUp()
self.config = {
"auth_url": "http://example.net:5000/v2.0/",
"region_name": "RegionOne",
"endpoint_type": consts.EndpointType.INTERNAL,
"https_insecure": False,
"https_cacert": "cacert",
"admin": {
"username": "admin",
"password": "myadminpass",
"tenant_name": "demo"
},
"users": [
{
"username": "user1",
"password": "userpass",
"tenant_name": "demo"
}
]
}
self.cred_builder_cls = credential.get_builder("openstack")
def test_validate(self):
self.cred_builder_cls.validate(self.config)
def test_validate_error(self):
self.assertRaises(jsonschema.ValidationError,
self.cred_builder_cls.validate,
{"foo": "bar"})
def test_build_credentials(self):
creds_builder = self.cred_builder_cls(self.config)
creds = creds_builder.build_credentials()
self.assertEqual({
"admin": {
"auth_url": "http://example.net:5000/v2.0/",
"username": "admin",
"password": "myadminpass",
"permission": consts.EndpointPermission.ADMIN,
"domain_name": None,
"endpoint": None,
"endpoint_type": consts.EndpointType.INTERNAL,
"https_cacert": "cacert",
"https_insecure": False,
"profiler_hmac_key": None,
"profiler_conn_str": None,
"project_domain_name": None,
"region_name": "RegionOne",
"tenant_name": "demo",
"user_domain_name": None,
},
"users": [
{
"auth_url": "http://example.net:5000/v2.0/",
"username": "user1",
"password": "userpass",
"permission": consts.EndpointPermission.USER,
"domain_name": None,
"endpoint": None,
"endpoint_type": consts.EndpointType.INTERNAL,
"https_cacert": "cacert",
"https_insecure": False,
"profiler_hmac_key": None,
"profiler_conn_str": None,
"project_domain_name": None,
"region_name": "RegionOne",
"tenant_name": "demo",
"user_domain_name": None,
}
]
}, creds)