Exemplo n.º 1
0
#    limitations under the License.

import abc
import copy
import inspect
import re

import six
import yaql
from yaql import exceptions as yaql_exc

from highlander import exceptions as exc
from highlander.openstack.common import log as logging
from highlander import yaql_utils

LOG = logging.getLogger(__name__)


class Evaluator(object):
    """Expression evaluator interface.

    Having this interface gives the flexibility to change the actual expression
    language used in Highlander DSL for conditions, output calculation etc.
    """
    @classmethod
    @abc.abstractmethod
    def validate(cls, expression):
        """Parse and validates the expression.

        :param expression: Expression string
        :return: True if expression is valid
Exemplo n.º 2
0
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.

import copy
import six

from highlander.db.v1 import api as db_api
from highlander import exceptions as exc
from highlander import expressions as expr
from highlander.openstack.common import log as logging
from highlander import utils
from highlander.maccleod import parser as spec_parser


LOG = logging.getLogger(__name__)


def validate_input(definition, spec, input):
    input_param_names = copy.copy((input or {}).keys())
    missing_param_names = []

    for p_name, p_value in six.iteritems(spec.get_input()):
        if p_value is utils.NotDefined and p_name not in input_param_names:
            missing_param_names.append(p_name)
        if p_name in input_param_names:
            input_param_names.remove(p_name)

    if missing_param_names or input_param_names:
        msg = 'Invalid input [name=%s, class=%s'
        msg_props = [definition.name, spec.__class__.__name__]