Merge "Clean up last mentions of Mistral environments"

This commit is contained in:
Jenkins 2017-06-15 16:34:24 +00:00 committed by Gerrit Code Review
commit dc1a93cbae
3 changed files with 11 additions and 53 deletions

View File

@ -0,0 +1,7 @@
---
upgrade:
- |
The environment configuration for deployments is now stored in a
file called ``plan-environment.yaml`` and stored in Swift with the
templates; Mistral is no longer used to store this data. Migration
of the existing plans is handled automatically.

View File

@ -28,8 +28,6 @@ import yaml
from heatclient.common import template_utils
from heatclient import exc as hc_exc
from keystoneauth1 import exceptions as keystoneauth_exc
from mistralclient.api import base as mistralclient_base
from osc_lib.command import command
from osc_lib import exceptions as oscexc
from osc_lib.i18n import _
@ -275,7 +273,7 @@ class DeployOvercloud(command.Command):
env['resource_registry'][name] = path
# Parameters are removed from the environment and sent to the update
# parameters action, this stores them in the Mistral environment and
# parameters action, this stores them in the plan environment and
# means the UI can find them.
if 'parameter_defaults' in env:
params = env.pop('parameter_defaults')
@ -289,49 +287,20 @@ class DeployOvercloud(command.Command):
# we need to manually add an environment in swift and for users
# custom environments passed to the deploy command.
# See bug: https://bugs.launchpad.net/tripleo/+bug/1623431
# Update plan env while taking care to migrate it from Mistral to
# Swift.
# Update plan env.
swift_path = "user-environment.yaml"
self.object_client.put_object(container_name, swift_path, contents)
env_missing = env_changed = False
try:
env = yaml.safe_load(self.object_client.get_object(
container_name, constants.PLAN_ENVIRONMENT)[1])
except ClientException:
env_missing = True
env = self.workflow_client.environments.get(
container_name).variables
# TODO(akrivoka): delete env from Mistral once tripleo-common
# change merges (https://review.openstack.org/#/c/452291/)
else:
# If the plan environment exists, the Mistral environment
# is superseded and should be cleaned up.
try:
self.workflow_client.environments.delete(container_name)
except (mistralclient_base.APIException,
keystoneauth_exc.http.NotFound):
pass
env = yaml.safe_load(self.object_client.get_object(
container_name, constants.PLAN_ENVIRONMENT)[1])
user_env = {'path': swift_path}
if user_env not in env['environments']:
env_changed = True
env['environments'].append(user_env)
if env_missing or env_changed:
yaml_string = yaml.safe_dump(env, default_flow_style=False)
self.object_client.put_object(
container_name, constants.PLAN_ENVIRONMENT, yaml_string)
# TODO(akrivoka): don't update env in Mistral once the
# tripleo-common change merges
# (https://review.openstack.org/#/c/452291/)
if env_missing:
self.workflow_client.environments.update(
name=container_name,
variables=env
)
def _upload_missing_files(self, container_name, files_dict, tht_root):
"""Find the files referenced in custom environments and upload them

View File

@ -14,8 +14,6 @@ import tempfile
import uuid
import yaml
from keystoneauth1 import exceptions as keystoneauth_exc
from mistralclient.api import base as mistralclient_base
from swiftclient import exceptions as swift_exc
from tripleo_common.utils import swift as swiftutils
from tripleo_common.utils import tarball
@ -196,22 +194,6 @@ def update_plan_from_templates(clients, name, tht_root, roles_file=None,
# when updating the templates. Once LP#1623431 is resolved we may
# need to special-case plan-environment.yaml to avoid this.
# TODO(jpichon): Remove all these references to Mistral once
# https://review.openstack.org/#/c/452291/ merges.
mistral = clients.workflow_engine
try:
mistral_env = mistral.environments.get(name)
except (mistralclient_base.APIException, keystoneauth_exc.http.NotFound):
# Plan was fully migrated, we can ignore.
pass
else:
mistral_env.variables['environments'] = []
mistral_env.variables['parameter_defaults'] = {}
mistral.environments.update(
name=name,
variables=mistral_env.variables
)
print("Uploading new plan files")
_upload_templates(swift_client, name, tht_root, roles_file)
_update_passwords(swift_client, name, passwords)