Browse Source

Merge "Add an action to upload validations to Swift"

changes/97/570697/1
Zuul 4 years ago
committed by Gerrit Code Review
parent
commit
d6c233599c
  1. 1
      setup.cfg
  2. 18
      tripleo_common/actions/base.py
  3. 18
      tripleo_common/actions/templates.py
  4. 7
      tripleo_common/actions/validations.py
  5. 3
      tripleo_common/constants.py

1
setup.cfg

@ -138,6 +138,7 @@ mistral.actions =
tripleo.validations.list_validations = tripleo_common.actions.validations:ListValidationsAction
tripleo.validations.run_validation = tripleo_common.actions.validations:RunValidationAction
tripleo.validations.verify_profiles = tripleo_common.actions.validations:VerifyProfilesAction
tripleo.validations.upload = tripleo_common.actions.validations:UploadValidationsAction
tripleo.files.file_exists = tripleo_common.actions.files:FileExists
tripleo.files.make_temp_dir = tripleo_common.actions.files:MakeTempDir
tripleo.files.remove_temp_dir = tripleo_common.actions.files:RemoveTempDir

18
tripleo_common/actions/base.py

@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import json
import tempfile
import zlib
from glanceclient.v2 import client as glanceclient
@ -31,6 +32,7 @@ from zaqarclient.queues.v2 import client as zaqarclient
from tripleo_common import constants
from tripleo_common.utils import keystone as keystone_utils
from tripleo_common.utils import tarball
class TripleOAction(actions.Action):
@ -234,3 +236,19 @@ class TripleOAction(actions.Action):
except swiftexceptions.ClientException:
# cache or container does not exist. Ignore
pass
class UploadDirectoryAction(TripleOAction):
"""Upload a directory to Swift."""
def __init__(self, container, dir_to_upload):
super(UploadDirectoryAction, self).__init__()
self.container = container
self.dir_to_upload = dir_to_upload
def run(self, context):
with tempfile.NamedTemporaryFile() as tmp_tarball:
tarball.create_tarball(self.dir_to_upload, tmp_tarball.name)
tarball.tarball_extract_to_swift_container(
self.get_object_client(context),
tmp_tarball.name,
self.container)

18
tripleo_common/actions/templates.py

@ -16,7 +16,6 @@ import jinja2
import logging
import os
import six
import tempfile as tf
import yaml
from heatclient import exc as heat_exc
@ -26,7 +25,6 @@ from swiftclient import exceptions as swiftexceptions
from tripleo_common.actions import base
from tripleo_common import constants
from tripleo_common.utils import plan as plan_utils
from tripleo_common.utils import tarball
LOG = logging.getLogger(__name__)
@ -66,21 +64,11 @@ class J2SwiftLoader(jinja2.BaseLoader):
raise jinja2.exceptions.TemplateNotFound(template)
class UploadTemplatesAction(base.TripleOAction):
class UploadTemplatesAction(base.UploadDirectoryAction):
"""Upload default heat templates for TripleO."""
def __init__(self, container=constants.DEFAULT_CONTAINER_NAME,
templates_path=constants.DEFAULT_TEMPLATES_PATH):
super(UploadTemplatesAction, self).__init__()
self.container = container
self.templates_path = templates_path
def run(self, context):
with tf.NamedTemporaryFile() as tmp_tarball:
tarball.create_tarball(self.templates_path, tmp_tarball.name)
tarball.tarball_extract_to_swift_container(
self.get_object_client(context),
tmp_tarball.name,
self.container)
dir_to_upload=constants.DEFAULT_TEMPLATES_PATH):
super(UploadTemplatesAction, self).__init__(container, dir_to_upload)
class UploadPlanEnvironmentAction(base.TripleOAction):

7
tripleo_common/actions/validations.py

@ -136,6 +136,13 @@ class RunValidationAction(base.TripleOAction):
return actions.Result(**mistral_result)
class UploadValidationsAction(base.UploadDirectoryAction):
"""Upload default validations for TripleO."""
def __init__(self, container=constants.VALIDATIONS_CONTAINER_NAME,
dir_to_upload=constants.DEFAULT_VALIDATIONS_PATH):
super(UploadValidationsAction, self).__init__(container, dir_to_upload)
class CheckBootImagesAction(base.TripleOAction):
"""Validate boot images"""

3
tripleo_common/constants.py

@ -44,6 +44,9 @@ DEFAULT_CONTAINER_NAME = 'overcloud'
#: The default name to use for the config files of the container
CONFIG_CONTAINER_NAME = 'overcloud-config'
#: The default name to use for the container for validations
VALIDATIONS_CONTAINER_NAME = 'tripleo-validations'
#: The default key to use for updating parameters in plan environment.
DEFAULT_PLAN_ENV_KEY = 'parameter_defaults'

Loading…
Cancel
Save