예제 #1
0
    def app_lifecycle_actions(self, context, conductor_obj, app_op, app,
                              hook_info):
        """ Perform lifecycle actions for an operation

        :param context: request context
        :param conductor_obj: conductor object
        :param app_op: AppOperator object
        :param app: AppOperator.Application object
        :param hook_info: LifecycleHookInfo object

        """

        # Semantic checks
        if hook_info.lifecycle_type == constants.APP_LIFECYCLE_TYPE_SEMANTIC_CHECK and \
                hook_info.mode == constants.APP_LIFECYCLE_MODE_AUTO and \
                hook_info.operation == constants.APP_APPLY_OP and \
                hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_PRE:
            raise exception.LifecycleSemanticCheckException(
                "Automatic apply is disabled for %s." % app.name)

        # TODO(dvoicule) remove once each app has its lifecycle operator and takes care of its rbd
        # this is here to keep the same functionality while decoupling
        # Rbd
        if hook_info.lifecycle_type == constants.APP_LIFECYCLE_TYPE_RBD:
            if hook_info.operation == constants.APP_APPLY_OP and \
                    hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_PRE:
                lifecycle_utils.create_rbd_provisioner_secrets(
                    app_op, app, hook_info)
            elif hook_info.operation == constants.APP_REMOVE_OP and \
                    hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_POST:
                lifecycle_utils.delete_rbd_provisioner_secrets(
                    app_op, app, hook_info)

        # TODO(dvoicule) remove once each app has its lifecycle operator and takes care of its resources
        # this is here to keep the same functionality while decoupling
        # Resources
        if hook_info.lifecycle_type == constants.APP_LIFECYCLE_TYPE_RESOURCE:
            if hook_info.operation == constants.APP_APPLY_OP and \
                    hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_PRE:
                lifecycle_utils.create_local_registry_secrets(
                    app_op, app, hook_info)
            elif hook_info.operation == constants.APP_REMOVE_OP and \
                    hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_POST:
                lifecycle_utils.delete_local_registry_secrets(
                    app_op, app, hook_info)
    def app_lifecycle_actions(self, context, conductor_obj, app_op, app,
                              hook_info):
        """ Perform lifecycle actions for an operation

        :param context: request context
        :param conductor_obj: conductor object
        :param app_op: AppOperator object
        :param app: AppOperator.Application object
        :param hook_info: LifecycleHookInfo object

        """
        # Operation
        if hook_info.lifecycle_type == constants.APP_LIFECYCLE_TYPE_OPERATION:
            if hook_info.operation == constants.APP_APPLY_OP:
                if hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_POST:
                    return self.post_apply(context, conductor_obj, hook_info)
            elif hook_info.operation == constants.APP_REMOVE_OP:
                if hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_POST:
                    return self.post_remove(context, conductor_obj, hook_info)

        # Rbd
        elif hook_info.lifecycle_type == constants.APP_LIFECYCLE_TYPE_RBD:
            if hook_info.operation == constants.APP_APPLY_OP and \
                    hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_PRE:
                return lifecycle_utils.create_rbd_provisioner_secrets(
                    app_op, app, hook_info)
            elif hook_info.operation == constants.APP_REMOVE_OP and \
                    hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_POST:
                return lifecycle_utils.delete_rbd_provisioner_secrets(
                    app_op, app, hook_info)

        # Resources
        elif hook_info.lifecycle_type == constants.APP_LIFECYCLE_TYPE_RESOURCE:
            if hook_info.operation == constants.APP_APPLY_OP and \
                    hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_PRE:
                return lifecycle_utils.create_local_registry_secrets(
                    app_op, app, hook_info)
            elif hook_info.operation == constants.APP_REMOVE_OP and \
                    hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_POST:
                return lifecycle_utils.delete_local_registry_secrets(
                    app_op, app, hook_info)

        # Use the default behaviour for other hooks
        super(SnmpAppLifecycleOperator,
              self).app_lifecycle_actions(context, conductor_obj, app_op, app,
                                          hook_info)
    def app_lifecycle_actions(self, context, conductor_obj, app_op, app, hook_info):
        """ Perform lifecycle actions for an operation

        :param context: request context
        :param conductor_obj: conductor object
        :param app_op: AppOperator object
        :param app: AppOperator.Application object
        :param hook_info: LifecycleHookInfo object

        """
        # Semantic checks
        if hook_info.lifecycle_type == constants.APP_LIFECYCLE_TYPE_SEMANTIC_CHECK:
            if hook_info.mode == constants.APP_LIFECYCLE_MODE_AUTO and \
                    hook_info.operation == constants.APP_APPLY_OP and \
                    hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_PRE:
                return self.pre_auto_apply_check(conductor_obj)

        # Rbd
        elif hook_info.lifecycle_type == constants.APP_LIFECYCLE_TYPE_RBD:
            if hook_info.operation == constants.APP_APPLY_OP and \
                    hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_PRE:
                return lifecycle_utils.create_rbd_provisioner_secrets(app_op, app, hook_info)
            elif hook_info.operation == constants.APP_REMOVE_OP and \
                    hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_POST:
                return lifecycle_utils.delete_rbd_provisioner_secrets(app_op, app, hook_info)

        # Resources
        elif hook_info.lifecycle_type == constants.APP_LIFECYCLE_TYPE_RESOURCE:
            if hook_info.operation == constants.APP_APPLY_OP and \
                    hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_PRE:
                return lifecycle_utils.create_local_registry_secrets(app_op, app, hook_info)
            elif hook_info.operation == constants.APP_REMOVE_OP and \
                    hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_POST:
                return lifecycle_utils.delete_local_registry_secrets(app_op, app, hook_info)

        # Armada apply retry
        elif hook_info.lifecycle_type == constants.APP_LIFECYCLE_TYPE_ARMADA_REQUEST:
            if hook_info.operation == constants.APP_APPLY_OP and \
                    hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_POST:
                return self.armada_apply_retry(app_op, app, hook_info)

        # Use the default behaviour for other hooks
        super(PlatformAppLifecycleOperator, self).app_lifecycle_actions(context, conductor_obj, app_op, app, hook_info)
예제 #4
0
    def app_lifecycle_actions(self, context, conductor_obj, app_op, app,
                              hook_info):
        """ Perform lifecycle actions for an operation

        :param context: request context
        :param conductor_obj: conductor object
        :param app_op: AppOperator object
        :param app: AppOperator.Application object
        :param hook_info: LifecycleHookInfo object

        """

        # Semantic checks
        if hook_info.lifecycle_type == constants.APP_LIFECYCLE_TYPE_SEMANTIC_CHECK:
            if hook_info.mode == constants.APP_LIFECYCLE_MODE_AUTO and \
                    hook_info.operation == constants.APP_APPLY_OP and \
                    hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_PRE:
                raise exception.LifecycleSemanticCheckException(
                    "Automatic apply is disabled for %s." % app.name)
            elif hook_info.mode == constants.APP_LIFECYCLE_MODE_AUTO and \
                    hook_info.operation == constants.APP_EVALUATE_REAPPLY_OP:
                # To reject the reapply evaluation an app can override this
                # hook and raise exception.LifecycleSemanticCheckException
                pass
            # Check if it is a delete operation
            elif hook_info.operation == constants.APP_DELETE_OP:
                try:
                    # Store the forbidden operations in a list
                    forbidden = conductor_obj.apps_metadata[
                        constants.APP_METADATA_APPS][app.name][
                            constants.APP_METADATA_BEHAVIOR][
                                constants.
                                APP_METADATA_FORBIDDEN_MANUAL_OPERATIONS]
                except KeyError:
                    pass
                else:
                    # Check if deletion is a forbidden operation
                    if constants.APP_DELETE_OP in forbidden:
                        raise exception.LifecycleSemanticCheckOpererationBlocked(
                            op=constants.APP_DELETE_OP.capitalize(),
                            app=app.name)

        # TODO(dvoicule) remove once each app has its lifecycle operator and takes care of its rbd
        # this is here to keep the same functionality while decoupling
        # Rbd
        elif hook_info.lifecycle_type == constants.APP_LIFECYCLE_TYPE_RBD:
            if hook_info.operation == constants.APP_APPLY_OP and \
                    hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_PRE:
                lifecycle_utils.create_rbd_provisioner_secrets(
                    app_op, app, hook_info)
            elif hook_info.operation == constants.APP_REMOVE_OP and \
                    hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_POST:
                lifecycle_utils.delete_rbd_provisioner_secrets(
                    app_op, app, hook_info)

        # TODO(dvoicule) remove once each app has its lifecycle operator and takes care of its resources
        # this is here to keep the same functionality while decoupling
        # Resources
        elif hook_info.lifecycle_type == constants.APP_LIFECYCLE_TYPE_RESOURCE:
            if hook_info.operation == constants.APP_APPLY_OP and \
                    hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_PRE:
                lifecycle_utils.create_local_registry_secrets(
                    app_op, app, hook_info)
            elif hook_info.operation == constants.APP_REMOVE_OP and \
                    hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_POST:
                lifecycle_utils.delete_local_registry_secrets(
                    app_op, app, hook_info)
예제 #5
0
    def app_lifecycle_actions(self, context, conductor_obj, app_op, app,
                              hook_info):
        """ Perform lifecycle actions for an operation

        :param context: request context
        :param conductor_obj: conductor object
        :param app_op: AppOperator object
        :param app: AppOperator.Application object
        :param hook_info: LifecycleHookInfo object

        """
        # Operation
        if hook_info.lifecycle_type == constants.APP_LIFECYCLE_TYPE_OPERATION:
            if hook_info.operation == constants.APP_APPLY_OP:
                if hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_PRE:
                    return self.pre_apply(context, conductor_obj, app,
                                          hook_info)
                elif hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_POST:
                    return self.post_apply(context, conductor_obj, app,
                                           hook_info)
            elif hook_info.operation == constants.APP_REMOVE_OP:
                if hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_PRE:
                    return self.pre_remove(context, conductor_obj, hook_info)
                elif hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_POST:
                    return self.post_remove(context, conductor_obj, hook_info)

        # Manifest
        elif hook_info.lifecycle_type == constants.APP_LIFECYCLE_TYPE_MANIFEST and \
                hook_info.operation == constants.APP_APPLY_OP and \
                hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_PRE:
            return self.pre_manifest_apply(app, app_op, hook_info)

        # Resource
        elif hook_info.lifecycle_type == constants.APP_LIFECYCLE_TYPE_RESOURCE:
            if hook_info.operation == constants.APP_APPLY_OP and \
                    hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_PRE:
                return self._create_app_specific_resources_pre_apply(
                    app_op, app, hook_info)
            elif hook_info.operation == constants.APP_REMOVE_OP and \
                    hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_POST:
                return self._delete_app_specific_resources_post_remove(
                    app_op, app, hook_info)

        # Rbd
        elif hook_info.lifecycle_type == constants.APP_LIFECYCLE_TYPE_RBD:
            if hook_info.operation == constants.APP_APPLY_OP and \
                    hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_PRE:
                return lifecycle_utils.create_rbd_provisioner_secrets(
                    app_op, app, hook_info)
            elif hook_info.operation == constants.APP_REMOVE_OP and \
                    hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_POST:
                return lifecycle_utils.delete_rbd_provisioner_secrets(
                    app_op, app, hook_info)

        # Semantic checks
        elif hook_info.lifecycle_type == constants.APP_LIFECYCLE_TYPE_SEMANTIC_CHECK:
            if hook_info.mode == constants.APP_LIFECYCLE_MODE_AUTO:
                if hook_info.operation == constants.APP_EVALUATE_REAPPLY_OP:
                    return self._semantic_check_evaluate_app_reapply(
                        app_op, app, hook_info)
                elif hook_info.operation == constants.APP_UPDATE_OP:
                    raise exception.LifecycleSemanticCheckOperationNotSupported(
                        mode=constants.APP_LIFECYCLE_MODE_AUTO,
                        op=constants.APP_UPDATE_OP,
                        name=app.name)
            elif hook_info.mode == constants.APP_LIFECYCLE_MODE_MANUAL and \
                    hook_info.operation == constants.APP_APPLY_OP and \
                        hook_info.relative_timing == constants.APP_LIFECYCLE_TIMING_PRE:
                return self._pre_manual_apply_check(conductor_obj, app,
                                                    hook_info)

        # Default behavior
        super(OpenstackAppLifecycleOperator,
              self).app_lifecycle_actions(context, conductor_obj, app_op, app,
                                          hook_info)