use Result from mistral_lib instead of mistral

This is part of the ongoing change to remove the mistral
dependency from tripleo-common and use mistral_lib instead

In order to do that we are using the Result class from mistral_lib

Change-Id: I59ce8c6d68de9e9719d84cbaa82462fbd8d647e2
Depends-on: Icc0036bae3c969112f2f67c4a8264bae18f3cc73
This commit is contained in:
Adriano Petrich 2017-04-07 14:24:48 +01:00
parent 4ba7d564db
commit 76b3e025b7
17 changed files with 115 additions and 118 deletions

View File

@ -15,7 +15,7 @@
import logging
import ironic_inspector_client
from mistral.workflow import utils as mistral_workflow_utils
from mistral_lib import actions
from oslo_utils import units
import six
@ -68,7 +68,7 @@ class RegisterOrUpdateNodes(base.TripleOAction):
ramdisk_name=self.ramdisk_name)
except Exception as err:
LOG.exception("Error registering nodes with ironic.")
return mistral_workflow_utils.Result(error=six.text_type(err))
return actions.Result(error=six.text_type(err))
class ValidateNodes(base.TripleOAction):
@ -86,10 +86,10 @@ class ValidateNodes(base.TripleOAction):
nodes.validate_nodes(self.nodes_json)
except exception.InvalidNode as err:
LOG.error("Validation of nodes failed: %s", err)
return mistral_workflow_utils.Result(error=str(err))
return actions.Result(error=str(err))
except Exception as err:
LOG.exception("Unexpected exception during node validation")
return mistral_workflow_utils.Result(error=str(err))
return actions.Result(error=str(err))
class ConfigureBootAction(base.TripleOAction):
@ -152,7 +152,7 @@ class ConfigureBootAction(base.TripleOAction):
LOG.debug("Configuring boot option for Node %s", self.node_uuid)
except Exception as err:
LOG.exception("Error configuring node boot options with Ironic.")
return mistral_workflow_utils.Result(error=six.text_type(err))
return actions.Result(error=six.text_type(err))
class ConfigureRootDeviceAction(base.TripleOAction):
@ -310,7 +310,7 @@ class UpdateNodeCapability(base.TripleOAction):
)
except Exception as err:
LOG.exception("Error updating node capability in ironic.")
return mistral_workflow_utils.Result(
return actions.Result(
error="%s: %s" % (type(err).__name__, str(err))
)
@ -332,7 +332,7 @@ class CellV2DiscoverHostsAction(base.TripleOAction):
)
except Exception as err:
LOG.exception("Error running cell_v2 discover_hosts")
return mistral_workflow_utils.Result(
return actions.Result(
error="%s: %s" % (type(err).__name__, str(err))
)

View File

@ -18,7 +18,7 @@ import time
from heatclient.common import deployment_utils
from heatclient import exc as heat_exc
from mistral.workflow import utils as mistral_workflow_utils
from mistral_lib import actions
from swiftclient import exceptions as swiftexceptions
from tripleo_common.actions import base
@ -122,7 +122,7 @@ class OrchestrationDeployAction(base.TripleOAction):
if body_json['deploy_status_code'] != 0:
error = "Heat deployment failed for '%s'" % self.name
return mistral_workflow_utils.Result(data=body_json, error=error)
return actions.Result(data=body_json, error=error)
class DeployStackAction(templates.ProcessTemplatesAction):
@ -159,7 +159,7 @@ class DeployStackAction(templates.ProcessTemplatesAction):
err_msg = ("Error retrieving environment for plan %s: %s" % (
self.container, err))
LOG.exception(err_msg)
return mistral_workflow_utils.Result(error=err_msg)
return actions.Result(error=err_msg)
try:
plan_utils.update_in_env(swift, env, 'parameter_defaults',
@ -168,14 +168,14 @@ class DeployStackAction(templates.ProcessTemplatesAction):
err_msg = ("Error updating environment for plan %s: %s" % (
self.container, err))
LOG.exception(err_msg)
return mistral_workflow_utils.Result(error=err_msg)
return actions.Result(error=err_msg)
# process all plan files and create or update a stack
processed_data = super(DeployStackAction, self).run(context)
# If we receive a 'Result' instance it is because the parent action
# had an error.
if isinstance(processed_data, mistral_workflow_utils.Result):
if isinstance(processed_data, actions.Result):
return processed_data
stack_args = processed_data.copy()
@ -224,7 +224,7 @@ class OvercloudRcAction(base.TripleOAction):
error = (
"The Heat stack {} could not be found. Make sure you have "
"deployed before calling this action.").format(self.container)
return mistral_workflow_utils.Result(error=error)
return actions.Result(error=error)
# We need to check parameter_defaults first for a user provided
# password. If that doesn't exist, we then should look in the
@ -237,7 +237,7 @@ class OvercloudRcAction(base.TripleOAction):
err_msg = ("Error retrieving environment for plan %s: %s" % (
self.container, err))
LOG.error(err_msg)
return mistral_workflow_utils.Result(error=err_msg)
return actions.Result(error=err_msg)
try:
parameter_defaults = env['parameter_defaults']
@ -248,6 +248,6 @@ class OvercloudRcAction(base.TripleOAction):
except KeyError:
error = ("Unable to find the AdminPassword in the plan "
"environment.")
return mistral_workflow_utils.Result(error=error)
return actions.Result(error=error)
return overcloudrc.create_overcloudrc(stack, self.no_proxy, admin_pass)

View File

@ -16,7 +16,7 @@ import fnmatch
import logging
import yaml
from mistral.workflow import utils as mistral_workflow_utils
from mistral_lib import actions
from swiftclient import exceptions as swiftexceptions
from tripleo_common.actions import base
@ -50,7 +50,7 @@ class GetCapabilitiesAction(base.TripleOAction):
err_msg = (
"Error parsing capabilities-map.yaml.")
LOG.exception(err_msg)
return mistral_workflow_utils.Result(error=err_msg)
return actions.Result(error=err_msg)
try:
container_files = swift.get_container(self.container)
container_file_list = [entry['name'] for entry
@ -58,7 +58,7 @@ class GetCapabilitiesAction(base.TripleOAction):
except Exception as swift_err:
err_msg = ("Error retrieving plan files: %s" % swift_err)
LOG.exception(err_msg)
return mistral_workflow_utils.Result(error=err_msg)
return actions.Result(error=err_msg)
try:
env = plan_utils.get_env(swift, self.container)
@ -66,7 +66,7 @@ class GetCapabilitiesAction(base.TripleOAction):
err_msg = ("Error retrieving environment for plan %s: %s" % (
self.container, err))
LOG.exception(err_msg)
return mistral_workflow_utils.Result(error=err_msg)
return actions.Result(error=err_msg)
selected_envs = [item['path'] for item in env['environments']
if 'path' in item]
@ -172,7 +172,7 @@ class UpdateCapabilitiesAction(base.TripleOAction):
err_msg = ("Error retrieving environment for plan %s: %s" % (
self.container, err))
LOG.exception(err_msg)
return mistral_workflow_utils.Result(error=err_msg)
return actions.Result(error=err_msg)
for k, v in self.environments.items():
found = False
@ -197,6 +197,6 @@ class UpdateCapabilitiesAction(base.TripleOAction):
except swiftexceptions.ClientException as err:
err_msg = "Error uploading to container: %s" % err
LOG.exception(err_msg)
return mistral_workflow_utils.Result(error=err_msg)
return actions.Result(error=err_msg)
return env

View File

@ -17,7 +17,7 @@ import time
from heatclient.common import template_utils
from heatclient import exc as heat_exc
from mistral.workflow import utils as mistral_workflow_utils
from mistral_lib import actions
from swiftclient import exceptions as swiftexceptions
from tripleo_common.actions import base
@ -57,7 +57,7 @@ class UpdateStackAction(templates.ProcessTemplatesAction):
except heat_exc.HTTPNotFound:
msg = "Error retrieving stack: %s" % self.container
LOG.exception(msg)
return mistral_workflow_utils.Result(error=msg)
return actions.Result(error=msg)
parameters = dict()
timestamp = int(time.time())
@ -73,7 +73,7 @@ class UpdateStackAction(templates.ProcessTemplatesAction):
err_msg = ("Error retrieving environment for plan %s: %s" % (
self.container, err))
LOG.exception(err_msg)
return mistral_workflow_utils.Result(error=err_msg)
return actions.Result(error=err_msg)
try:
plan_utils.update_in_env(swift, env, 'parameter_defaults',
@ -82,14 +82,14 @@ class UpdateStackAction(templates.ProcessTemplatesAction):
err_msg = ("Error updating environment for plan %s: %s" % (
self.container, err))
LOG.exception(err_msg)
return mistral_workflow_utils.Result(error=err_msg)
return actions.Result(error=err_msg)
# process all plan files and create or update a stack
processed_data = super(UpdateStackAction, self).run(context)
# If we receive a 'Result' instance it is because the parent action
# had an error.
if isinstance(processed_data, mistral_workflow_utils.Result):
if isinstance(processed_data, actions.Result):
return processed_data
stack_args = processed_data.copy()

View File

@ -30,7 +30,7 @@ import logging
import uuid
from heatclient import exc as heat_exc
from mistral.workflow import utils as mistral_workflow_utils
from mistral_lib import actions
from swiftclient import exceptions as swiftexceptions
from tripleo_common.actions import base
@ -61,7 +61,7 @@ class GetParametersAction(templates.ProcessTemplatesAction):
# If we receive a 'Result' instance it is because the parent action
# had an error.
if isinstance(processed_data, mistral_workflow_utils.Result):
if isinstance(processed_data, actions.Result):
return processed_data
processed_data['show_nested'] = True
@ -76,7 +76,7 @@ class GetParametersAction(templates.ProcessTemplatesAction):
err_msg = ("Error retrieving environment for plan %s: %s" % (
self.container, err))
LOG.exception(err_msg)
return mistral_workflow_utils.Result(error=err_msg)
return actions.Result(error=err_msg)
params = env.get('parameter_defaults')
@ -114,7 +114,7 @@ class ResetParametersAction(base.TripleOAction):
err_msg = ("Error retrieving environment for plan %s: %s" % (
self.container, err))
LOG.exception(err_msg)
return mistral_workflow_utils.Result(error=err_msg)
return actions.Result(error=err_msg)
try:
plan_utils.update_in_env(swift, env, 'parameter_defaults',
@ -123,7 +123,7 @@ class ResetParametersAction(base.TripleOAction):
err_msg = ("Error updating environment for plan %s: %s" % (
self.container, err))
LOG.exception(err_msg)
return mistral_workflow_utils.Result(error=err_msg)
return actions.Result(error=err_msg)
self.cache_delete(context,
self.container,
@ -149,7 +149,7 @@ class UpdateParametersAction(base.TripleOAction):
err_msg = ("Error retrieving environment for plan %s: %s" % (
self.container, err))
LOG.exception(err_msg)
return mistral_workflow_utils.Result(error=err_msg)
return actions.Result(error=err_msg)
try:
plan_utils.update_in_env(swift, env, 'parameter_defaults',
@ -158,7 +158,7 @@ class UpdateParametersAction(base.TripleOAction):
err_msg = ("Error updating environment for plan %s: %s" % (
self.container, err))
LOG.exception(err_msg)
return mistral_workflow_utils.Result(error=err_msg)
return actions.Result(error=err_msg)
self.cache_delete(context,
self.container,
@ -205,7 +205,7 @@ class GeneratePasswordsAction(base.TripleOAction):
err_msg = ("Error retrieving environment for plan %s: %s" % (
self.container, err))
LOG.exception(err_msg)
return mistral_workflow_utils.Result(error=err_msg)
return actions.Result(error=err_msg)
try:
stack_env = heat.stacks.environment(
@ -230,7 +230,7 @@ class GeneratePasswordsAction(base.TripleOAction):
except swiftexceptions.ClientException as err:
err_msg = "Error uploading to container: %s" % err
LOG.exception(err_msg)
return mistral_workflow_utils.Result(error=err_msg)
return actions.Result(error=err_msg)
self.cache_delete(context,
self.container,
@ -259,7 +259,7 @@ class GetPasswordsAction(base.TripleOAction):
err_msg = ("Error retrieving environment for plan %s: %s" % (
self.container, err))
LOG.exception(err_msg)
return mistral_workflow_utils.Result(error=err_msg)
return actions.Result(error=err_msg)
parameter_defaults = env.get('parameter_defaults', {})
passwords = env.get('passwords', {})
@ -423,7 +423,7 @@ class GetFlattenedParametersAction(GetParametersAction):
# If we receive a 'Result' instance it is because the parent action
# had an error.
if isinstance(processed_data, mistral_workflow_utils.Result):
if isinstance(processed_data, actions.Result):
return processed_data
if processed_data['heat_resource_tree']:
@ -458,7 +458,7 @@ class GetProfileOfFlavorAction(base.TripleOAction):
compute_client)
except exception.DeriveParamsError as err:
LOG.error('Derive Params Error: %s', err)
return mistral_workflow_utils.Result(error=str(err))
return actions.Result(error=str(err))
class RotateFernetKeysAction(GetPasswordsAction):
@ -481,7 +481,7 @@ class RotateFernetKeysAction(GetPasswordsAction):
err_msg = ("Error retrieving environment for plan %s: %s" % (
self.container, err))
LOG.exception(err_msg)
return mistral_workflow_utils.Result(error=err_msg)
return actions.Result(error=err_msg)
parameter_defaults = env.get('parameter_defaults', {})
passwords = self._get_overriden_passwords(env.get('passwords', {}),
@ -500,7 +500,7 @@ class RotateFernetKeysAction(GetPasswordsAction):
except swiftexceptions.ClientException as err:
err_msg = "Error uploading to container: %s" % err
LOG.exception(err_msg)
return mistral_workflow_utils.Result(error=err_msg)
return actions.Result(error=err_msg)
self.cache_delete(context,
self.container,

View File

@ -20,7 +20,7 @@ import yaml
from heatclient import exc as heatexceptions
from keystoneauth1 import exceptions as keystoneauth_exc
from mistral.workflow import utils as mistral_workflow_utils
from mistral_lib import actions
from mistralclient.api import base as mistralclient_base
from oslo_concurrency import processutils
import six
@ -60,14 +60,14 @@ class CreateContainerAction(base.TripleOAction):
if not pattern_validator(constants.PLAN_NAME_PATTERN, self.container):
message = ("Unable to create plan. The plan name must "
"only contain letters, numbers or dashes")
return mistral_workflow_utils.Result(error=message)
return actions.Result(error=message)
# checks to see if a container with that name exists
if self.container in [container["name"] for container in
oc.get_account()[1]]:
result_string = ("A container with the name %s already"
" exists.") % self.container
return mistral_workflow_utils.Result(error=result_string)
return actions.Result(error=result_string)
oc.put_container(self.container, headers=default_container_headers)
@ -177,7 +177,7 @@ class DeletePlanAction(base.TripleOAction):
error_text = six.text_type(err)
if error_text:
return mistral_workflow_utils.Result(error=error_text)
return actions.Result(error=error_text)
class ListRolesAction(base.TripleOAction):
@ -202,7 +202,7 @@ class ListRolesAction(base.TripleOAction):
err_msg = ("Error retrieving roles data from deployment plan: %s"
% err)
LOG.exception(err_msg)
return mistral_workflow_utils.Result(error=err_msg)
return actions.Result(error=err_msg)
return [role['name'] for role in roles_data]
@ -263,15 +263,15 @@ class ExportPlanAction(base.TripleOAction):
self._create_and_upload_tarball(swift, tmp_dir)
except swiftexceptions.ClientException as err:
msg = "Error attempting an operation on container: %s" % err
return mistral_workflow_utils.Result(error=msg)
return actions.Result(error=msg)
except (OSError, IOError) as err:
msg = "Error while writing file: %s" % err
return mistral_workflow_utils.Result(error=msg)
return actions.Result(error=msg)
except processutils.ProcessExecutionError as err:
msg = "Error while creating a tarball: %s" % err
return mistral_workflow_utils.Result(error=msg)
return actions.Result(error=msg)
except Exception as err:
msg = "Error exporting plan: %s" % err
return mistral_workflow_utils.Result(error=msg)
return actions.Result(error=msg)
finally:
shutil.rmtree(tmp_dir)

View File

@ -15,8 +15,7 @@
import collections
import logging
from mistral.workflow import utils as mistral_workflow_utils
from mistral_lib import actions
from tripleo_common.actions import parameters as parameters_actions
from tripleo_common.actions import templates
@ -72,11 +71,11 @@ class ScaleDownAction(templates.ProcessTemplatesAction):
update_params_action = parameters_actions.UpdateParametersAction(
parameters, self.container)
updated_plan = update_params_action.run(context)
if isinstance(updated_plan, mistral_workflow_utils.Result):
if isinstance(updated_plan, actions.Result):
return updated_plan
processed_data = super(ScaleDownAction, self).run(context)
if isinstance(processed_data, mistral_workflow_utils.Result):
if isinstance(processed_data, actions.Result):
return processed_data
update.add_breakpoints_cleanup_into_env(processed_data['environment'])

View File

@ -15,7 +15,7 @@
import uuid
from mistral.workflow import utils as mistral_workflow_utils
from mistral_lib import actions
from six.moves import urllib
from swiftclient import exceptions as swiftexceptions
from swiftclient.utils import generate_temp_url
@ -44,7 +44,7 @@ class SwiftInformationAction(base.TripleOAction):
except Exception as err:
error = str(err)
return mistral_workflow_utils.Result(data=data, error=error)
return actions.Result(data=data, error=error)
class SwiftTempUrlAction(base.TripleOAction):

View File

@ -22,7 +22,7 @@ import tempfile as tf
import yaml
from heatclient.common import template_utils
from mistral.workflow import utils as mistral_workflow_utils
from mistral_lib import actions
from swiftclient import exceptions as swiftexceptions
from tripleo_common.actions import base
@ -259,7 +259,7 @@ class ProcessTemplatesAction(base.TripleOAction):
err_msg = ("Error retrieving environment for plan %s: %s" % (
self.container, err))
LOG.exception(err_msg)
return mistral_workflow_utils.Result(error=err_msg)
return actions.Result(error=error_text)
try:
# if the jinja overcloud template exists, process it and write it
@ -271,7 +271,7 @@ class ProcessTemplatesAction(base.TripleOAction):
self._process_custom_roles(context)
except Exception as err:
LOG.exception("Error occurred while processing custom roles.")
return mistral_workflow_utils.Result(error=six.text_type(err))
return actions.Result(error=six.text_type(err))
template_name = plan_env.get('template')
environments = plan_env.get('environments')
@ -337,7 +337,7 @@ class ProcessTemplatesAction(base.TripleOAction):
os.remove(f)
if error_text:
return mistral_workflow_utils.Result(error=error_text)
return actions.Result(error=error_text)
files = dict(list(template_files.items()) + list(env_files.items()))

View File

@ -12,7 +12,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from mistral.workflow import utils as mistral_workflow_utils
from mistral_lib import actions
from mistralclient.api import base as mistralclient_api
from oslo_concurrency.processutils import ProcessExecutionError
@ -78,7 +78,7 @@ class Enabled(base.TripleOAction):
else:
return_value['stdout'] = 'Validations are disabled'
mistral_result = {"error": return_value}
return mistral_workflow_utils.Result(**mistral_result)
return actions.Result(**mistral_result)
class ListValidationsAction(base.TripleOAction):
@ -133,7 +133,7 @@ class RunValidationAction(base.TripleOAction):
finally:
if identity_file:
utils.cleanup_identity_file(identity_file)
return mistral_workflow_utils.Result(**mistral_result)
return actions.Result(**mistral_result)
class CheckBootImagesAction(base.TripleOAction):
@ -162,9 +162,9 @@ class CheckBootImagesAction(base.TripleOAction):
}
if messages:
mistral_result = mistral_workflow_utils.Result(error=return_value)
mistral_result = actions.Result(error=return_value)
else:
mistral_result = mistral_workflow_utils.Result(data=return_value)
mistral_result = actions.Result(data=return_value)
return mistral_result
@ -257,7 +257,7 @@ class CheckFlavorsAction(base.TripleOAction):
else:
mistral_result = {'data': return_value}
return mistral_workflow_utils.Result(**mistral_result)
return actions.Result(**mistral_result)
class CheckNodeBootConfigurationAction(base.TripleOAction):
@ -311,7 +311,7 @@ class CheckNodeBootConfigurationAction(base.TripleOAction):
else:
mistral_result = {'data': return_value}
return mistral_workflow_utils.Result(**mistral_result)
return actions.Result(**mistral_result)
class VerifyProfilesAction(base.TripleOAction):
@ -398,7 +398,7 @@ class VerifyProfilesAction(base.TripleOAction):
else:
mistral_result = {'data': return_value}
return mistral_workflow_utils.Result(**mistral_result)
return actions.Result(**mistral_result)
def _node_get_capabilities(self, node):
"""Get node capabilities."""
@ -476,4 +476,4 @@ class CheckNodesCountAction(base.TripleOAction):
else:
mistral_result = {'data': return_value}
return mistral_workflow_utils.Result(**mistral_result)
return actions.Result(**mistral_result)

View File

@ -20,7 +20,6 @@ import tempfile
from git import Repo
import six
from mistral.workflow import utils as mistral_workflow_utils
from mistral_lib import actions
LOG = logging.getLogger(__name__)
@ -54,7 +53,7 @@ class GitCloneAction(actions.Action):
except Exception:
err_msg = ("Error cloning remote repository: %s " % url_bits[0])
LOG.exception(err_msg)
return mistral_workflow_utils.Result(error=err_msg)
return actions.Result(error=err_msg)
# if a tag value was given, checkout that tag
if len(url_bits) > 1:
@ -70,7 +69,7 @@ class GitCloneAction(actions.Action):
LOG.exception(err_msg)
if err_msg:
return mistral_workflow_utils.Result(error=err_msg)
return actions.Result(error=err_msg)
return local_dir_path
@ -93,7 +92,7 @@ class GitCleanupAction(actions.Action):
shutil.rmtree(path)
except IndexError as idx_err:
LOG.exception("Directory not found: %s" % target_path)
return mistral_workflow_utils.Result(error=six.text_type(idx_err))
return actions.Result(error=six.text_type(idx_err))
except OSError as os_err:
LOG.exception("Error removing directory: %s" % target_path)
return mistral_workflow_utils.Result(error=six.text_type(os_err))
return actions.Result(error=six.text_type(os_err))

View File

@ -16,7 +16,7 @@ import mock
import yaml
from heatclient import exc as heat_exc
from mistral.workflow import utils as mistral_workflow_utils
from mistral_lib import actions
from swiftclient import exceptions as swiftexceptions
from tripleo_common.actions import deployment
@ -117,7 +117,7 @@ class OrchestrationDeployActionTest(base.TestCase):
action = deployment.OrchestrationDeployAction(self.server_id,
self.config, self.name)
expected = mistral_workflow_utils.Result(
expected = actions.Result(
data={"deploy_status_code": 0},
error=None)
self.assertEqual(expected, action.run(context=mock_ctx))
@ -156,7 +156,7 @@ class OrchestrationDeployActionTest(base.TestCase):
action = deployment.OrchestrationDeployAction(self.server_id,
self.config, self.name)
expected = mistral_workflow_utils.Result(
expected = actions.Result(
data={},
error="Timeout for heat deployment 'name'")
self.assertEqual(expected, action.run(mock_ctx))
@ -190,7 +190,7 @@ class OrchestrationDeployActionTest(base.TestCase):
action = deployment.OrchestrationDeployAction(self.server_id,
self.config, self.name)
expected = mistral_workflow_utils.Result(
expected = actions.Result(
data={"deploy_status_code": 1},
error="Heat deployment failed for 'name'")
self.assertEqual(expected, action.run(mock_ctx))

View File

@ -15,7 +15,7 @@
import mock
import yaml
from mistral.workflow import utils as mistral_workflow_utils
from mistral_lib import actions
from swiftclient import exceptions as swiftexceptions
from tripleo_common.actions import heat_capabilities
@ -150,7 +150,7 @@ class GetCapabilitiesActionTest(base.TestCase):
get_obj_client_mock.return_value = swift
action = heat_capabilities.GetCapabilitiesAction(self.container_name)
expected = mistral_workflow_utils.Result(
expected = actions.Result(
data=None,
error="Error parsing capabilities-map.yaml.")
self.assertEqual(expected, action.run(mock_ctx))
@ -168,7 +168,7 @@ class GetCapabilitiesActionTest(base.TestCase):
get_obj_client_mock.return_value = swift
action = heat_capabilities.GetCapabilitiesAction(self.container_name)
expected = mistral_workflow_utils.Result(
expected = actions.Result(
data=None,
error="Error retrieving environment for plan test-container: "
"test-container")
@ -323,7 +323,7 @@ class UpdateCapabilitiesActionTest(base.TestCase):
action = heat_capabilities.UpdateCapabilitiesAction(
{}, self.container_name)
expected = mistral_workflow_utils.Result(
expected = actions.Result(
data=None,
error="Error retrieving environment for plan test-container: "
"test-container"

View File

@ -15,7 +15,7 @@
import mock
from heatclient import exc as heatexceptions
from mistral.workflow import utils as mistral_workflow_utils
from mistral_lib import actions
from oslo_concurrency import processutils
from swiftclient import exceptions as swiftexceptions
@ -113,7 +113,7 @@ class CreateContainerActionTest(base.TestCase):
error_str = ('A container with the name %s already'
' exists.') % self.container_name
self.assertEqual(result, mistral_workflow_utils.Result(
self.assertEqual(result, actions.Result(
None, error_str))
@mock.patch('tripleo_common.actions.base.TripleOAction.get_object_client')
@ -128,7 +128,7 @@ class CreateContainerActionTest(base.TestCase):
error_str = ("Unable to create plan. The plan name must only contain "
"letters, numbers or dashes")
self.assertEqual(result, mistral_workflow_utils.Result(
self.assertEqual(result, actions.Result(
None, error_str))

View File

@ -14,7 +14,7 @@
# under the License.
import mock
from mistral.workflow import utils as mistral_workflow_utils
from mistral_lib import actions
from tripleo_common.actions import swifthelper
from tripleo_common.tests import base
@ -39,8 +39,7 @@ class SwiftInformationActionTest(base.TestCase):
'container_url': 'test_uri/{}'.format(self.container_name),
'auth_key': 'test_token'
}
return_obj = mistral_workflow_utils.Result(data=return_data,
error=None)
return_obj = actions.Result(data=return_data, error=None)
self.assertEqual(return_obj, self.action.run(mock_ctx))
oc_mock.head_container.assert_called_with(self.container_name)
@ -53,7 +52,7 @@ class SwiftInformationActionTest(base.TestCase):
oc_mock.head_container.side_effect = fail
self.action.get_object_client.return_value = oc_mock
return_obj = mistral_workflow_utils.Result(data=None, error='failure')
return_obj = actions.Result(data=None, error='failure')
self.assertEqual(return_obj, self.action.run(mock_ctx))

View File

@ -16,7 +16,7 @@ import collections
import mock
from uuid import uuid4
from mistral.workflow import utils as mistral_workflow_utils
from mistral_lib import actions
from oslo_concurrency.processutils import ProcessExecutionError
from tripleo_common.actions import validations
@ -166,7 +166,7 @@ class RunValidationActionTest(base.TestCase):
mock_write_identity_file.return_value = 'identity_file_path'
mock_run_validation.return_value = 'output', 'error'
action = validations.RunValidationAction('validation')
expected = mistral_workflow_utils.Result(
expected = actions.Result(
data={
'stdout': 'output',
'stderr': 'error'
@ -200,7 +200,7 @@ class RunValidationActionTest(base.TestCase):
mock_run_validation.side_effect = ProcessExecutionError(
stdout='output', stderr='error')
action = validations.RunValidationAction('validation')
expected = mistral_workflow_utils.Result(
expected = actions.Result(
data=None,
error={
'stdout': 'output',
@ -231,7 +231,7 @@ class TestCheckBootImagesAction(base.TestCase):
'._check_for_image')
def test_run(self, mock_check_for_image):
mock_check_for_image.side_effect = ['12345', '67890']
expected = mistral_workflow_utils.Result(
expected = actions.Result(
data={
'kernel_id': '12345',
'ramdisk_id': '67890',
@ -341,7 +341,7 @@ class TestCheckFlavorsAction(base.TestCase):
'role1': ('flavor1', 1),
}
expected = mistral_workflow_utils.Result(
expected = actions.Result(
data={
'flavors': {
'flavor1': (
@ -367,7 +367,7 @@ class TestCheckFlavorsAction(base.TestCase):
'role3': ('flavor3', 1),
}
expected = mistral_workflow_utils.Result(
expected = actions.Result(
data={
'flavors': {
'flavor2': (
@ -404,7 +404,7 @@ class TestCheckFlavorsAction(base.TestCase):
'role4': ('does_not_exist', 1),
}
expected = mistral_workflow_utils.Result(
expected = actions.Result(
error={
'errors': [
"Flavor '%s' provided for the role '%s', does not "
@ -440,7 +440,7 @@ class TestCheckNodeBootConfigurationAction(base.TestCase):
self.ctx = mock.MagicMock()
def test_run_success(self):
expected = mistral_workflow_utils.Result(
expected = actions.Result(
data={'errors': [], 'warnings': []}
)
@ -453,7 +453,7 @@ class TestCheckNodeBootConfigurationAction(base.TestCase):
self.assertEqual(expected, action.run(self.ctx))
def test_run_invalid_ramdisk(self):
expected = mistral_workflow_utils.Result(
expected = actions.Result(
error={
'errors': [
'Node 100f2cf6-06de-480e-a73e-6fdf6c9962b7 has an '
@ -473,7 +473,7 @@ class TestCheckNodeBootConfigurationAction(base.TestCase):
self.assertEqual(expected, action.run(self.ctx))
def test_no_boot_option_local(self):
expected = mistral_workflow_utils.Result(
expected = actions.Result(
data={
'errors': [],
'warnings': [
@ -543,7 +543,7 @@ class TestVerifyProfilesAction(base.TestCase):
self.nodes[:] = [self._get_fake_node(profile='fake'),
self._get_fake_node(profile='fake')]
expected = mistral_workflow_utils.Result(
expected = actions.Result(
data={
'errors': [],
'warnings': [],
@ -554,7 +554,7 @@ class TestVerifyProfilesAction(base.TestCase):
self.nodes[:] = [self._get_fake_node(profile='compute'),
self._get_fake_node(profile='control')]
expected = mistral_workflow_utils.Result(
expected = actions.Result(
data={
'errors': [],
'warnings': [],
@ -567,7 +567,7 @@ class TestVerifyProfilesAction(base.TestCase):
self._get_fake_node(profile='foobar'),
self._get_fake_node(profile='control')]
expected = mistral_workflow_utils.Result(
expected = actions.Result(
data={
'warnings': [
'There are 1 ironic nodes with no profile that will not '
@ -583,7 +583,7 @@ class TestVerifyProfilesAction(base.TestCase):
self._get_fake_node(profile='compute'),
self._get_fake_node(profile='control')]
expected = mistral_workflow_utils.Result(
expected = actions.Result(
data={
'warnings': ["2 nodes with profile compute won't be used for "
"deployment now"],
@ -593,7 +593,7 @@ class TestVerifyProfilesAction(base.TestCase):
def test_no_nodes(self):
# One error per each flavor
expected = mistral_workflow_utils.Result(
expected = actions.Result(
error={'errors': ['Error: only 0 of 1 requested ironic nodes are '
'tagged to profile compute (for flavor '
'compute)\n'
@ -619,7 +619,7 @@ class TestVerifyProfilesAction(base.TestCase):
def test_not_enough_nodes(self):
self.nodes[:] = [self._get_fake_node(profile='compute')]
expected = mistral_workflow_utils.Result(
expected = actions.Result(
error={'errors': ['Error: only 0 of 1 requested ironic nodes are '
'tagged to profile control (for flavor '
'control).\n'
@ -636,7 +636,7 @@ class TestVerifyProfilesAction(base.TestCase):
provision_state='active'),
self._get_fake_node(profile='control')]
expected = mistral_workflow_utils.Result(
expected = actions.Result(
data={
'errors': [],
'warnings': [],
@ -652,7 +652,7 @@ class TestVerifyProfilesAction(base.TestCase):
provision_state='cleaning'),
self._get_fake_node(profile='compute',
provision_state='error')]
expected = mistral_workflow_utils.Result(
expected = actions.Result(
error={
'warnings': [
'There are 1 ironic nodes with no profile that will not '
@ -683,7 +683,7 @@ class TestVerifyProfilesAction(base.TestCase):
self.nodes[:] = [self._get_fake_node(profile=None)]
self.flavors = {'baremetal': (
self._get_fake_flavor('baremetal', None), 1)}
expected = mistral_workflow_utils.Result(
expected = actions.Result(
error={
'warnings': [
'There are 1 ironic nodes with no profile that will not '
@ -734,7 +734,7 @@ class TestCheckNodesCountAction(base.TestCase):
action = validations.CheckNodesCountAction(**action_args)
result = action.run(self.ctx)
expected = mistral_workflow_utils.Result(
expected = actions.Result(
data={
'result': {
'requested_count': 2,
@ -756,7 +756,7 @@ class TestCheckNodesCountAction(base.TestCase):
action = validations.CheckNodesCountAction(**action_args)
result = action.run(self.ctx)
expected = mistral_workflow_utils.Result(
expected = actions.Result(
error={
'errors': [
'Only 0 nodes are exposed to Nova of 3 requests. Check '
@ -779,7 +779,7 @@ class TestCheckNodesCountAction(base.TestCase):
action = validations.CheckNodesCountAction(**action_args)
result = action.run(self.ctx)
expected = mistral_workflow_utils.Result(
expected = actions.Result(
data={
'errors': [],
'warnings': [],
@ -799,7 +799,7 @@ class TestCheckNodesCountAction(base.TestCase):
action = validations.CheckNodesCountAction(**action_args)
result = action.run(self.ctx)
expected = mistral_workflow_utils.Result(
expected = actions.Result(
error={
'errors': [
"Not enough baremetal nodes - available: 3, requested: 4"],
@ -821,7 +821,7 @@ class TestCheckNodesCountAction(base.TestCase):
action = validations.CheckNodesCountAction(**action_args)
result = action.run(self.ctx)
expected = mistral_workflow_utils.Result(
expected = actions.Result(
data={
'errors': [],
'warnings': [],
@ -842,7 +842,7 @@ class TestCheckNodesCountAction(base.TestCase):
action = validations.CheckNodesCountAction(**action_args)
result = action.run(self.ctx)
expected = mistral_workflow_utils.Result(
expected = actions.Result(
error={
'errors': [
'Not enough baremetal nodes - available: 3, requested: 4'],
@ -866,7 +866,7 @@ class TestCheckNodesCountAction(base.TestCase):
action = validations.CheckNodesCountAction(**action_args)
result = action.run(self.ctx)
expected = mistral_workflow_utils.Result(
expected = actions.Result(
error={
'errors': [
'Not enough baremetal nodes - available: 3, requested: 4'],

View File

@ -19,7 +19,7 @@ import tempfile
import uuid
import git
from mistral.workflow import utils as mistral_workflow_utils
from mistral_lib import actions
from tripleo_common.actions import vcs
from tripleo_common.tests import base
@ -56,7 +56,7 @@ class GitCloneActionTest(base.TestCase):
action = vcs.GitCloneAction(self.container, self.git_url)
result = action.run(self.ctx)
expected = mistral_workflow_utils.Result(
expected = actions.Result(
error="Error cloning remote repository: %s " % self.git_url
)
@ -82,7 +82,7 @@ class GitCloneActionTest(base.TestCase):
err_msg = ("Error finding %s reference from remote repository" %
self.tag_ref)
expected = mistral_workflow_utils.Result(error=err_msg)
expected = actions.Result(error=err_msg)
self.assertEqual(result, expected, "Error messages don't match.")
@ -107,7 +107,7 @@ class GitCloneActionTest(base.TestCase):
err_msg = ("Error checking out %s reference from remote "
"repository %s" % (self.tag_ref, self.git_url))
expected = mistral_workflow_utils.Result(error=err_msg)
expected = actions.Result(error=err_msg)
self.assertEqual(result, expected, "Error messages don't match.")