# Path: muranoagent/exceptions.py
# class AgentException(Exception):
# class CustomException(AgentException):
# class IncorrectFormat(AgentException):
#     def __init__(self, code, message=None, additional_data=None):
#     def error_code(self):
#     def additional_data(self):
#     def __init__(self, code, message=None, additional_data=None):


import semantic_version
from muranoagent import exceptions as exc
# Copyright (c) 2017 Mirantis Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.




max_format_version = semantic_version.Spec('<=2.2.0')


def validate_plan(plan):
    plan_format_version = semantic_version.Version(
        plan.get('FormatVersion', '1.0.0'))

    if plan_format_version not in max_format_version:
        # NOTE(kazitsev) this is Version in Spec not str in str
        raise exc.IncorrectFormat(
            9,

# Path: muranoagent/exceptions.py
# class AgentException(Exception):
# class CustomException(AgentException):
# class IncorrectFormat(AgentException):
#     def __init__(self, code, message=None, additional_data=None):
#     def error_code(self):
#     def additional_data(self):
#     def __init__(self, code, message=None, additional_data=None):


# Path: muranoagent/validation.py
import semantic_version
from muranoagent import exceptions as exc

# Copyright (c) 2017 Mirantis Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.




max_format_version = semantic_version.Spec('<=2.2.0')


def validate_plan(plan):
    plan_format_version = semantic_version.Version(
        plan.get('FormatVersion', '1.0.0'))

    if plan_format_version not in max_format_version:
        # NOTE(kazitsev) this is Version in Spec not str in str
        raise exc.IncorrectFormat(
            9,

            "Unsupported format version {0} "