summaryrefslogtreecommitdiffstats
path: root/ci/config_tpl/juju2/bundle_tpl/neutron-ovs.yaml
blob: 6e7fa7ec5250a21fd83e8ec37068879f2cc3dc67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
    neutron-openvswitch:
      charm: ./{{ ubuntu.release }}/neutron-openvswitch
{% if os.service.bindings %}
      bindings:
        data: *overlay-space
      options:
{% else %}
      options:
{% if opnfv.spaces_dict.data is defined %}
        os-data-network: {{ opnfv.spaces_dict.data.cidr }}
{% endif %}
{% endif %}
{% if os.git_repo.origin_git %}
        openstack-origin-git: "{{ os.git_repo.branch }}"
{% endif %}
{% if os.network.dpdk %}
        enable-dpdk: true
        #dpdk-driver: uio_pci_generic
        #data-port: ""
        #default-socket-memory: 1024
        #default-socket-cores: 1
{% endif %}
{% if os.network.controller == 'nosdn' %}
        bridge-mappings: physnet1:br-data
        #data-port: *data-port
{% else %}
        ext-port: {{ opnfv.ext_port }}
{% endif %}
{# Empty block to avoid bad block trim #}
} /* Literal.String.Doc */ .highlight .s2 { color: #e6db74 } /* Literal.String.Double */ .highlight .se { color: #ae81ff } /* Literal.String.Escape */ .highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */ .highlight .si { color: #e6db74 } /* Literal.String.Interpol */ .highlight .sx { color: #e6db74 } /* Literal.String.Other */ .highlight .sr { color: #e6db74 } /* Literal.String.Regex */ .highlight .s1 { color: #e6db74 } /* Literal.String.Single */ .highlight .ss { color: #e6db74 } /* Literal.String.Symbol */ .highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #a6e22e } /* Name.Function.Magic */ .highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ } @media (prefers-color-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
#    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.

from toscaparser.common import exception
from toscaparser.elements.artifacttype import ArtifactTypeDef
from toscaparser.elements.entity_type import EntityType
from toscaparser.elements.grouptype import GroupType
import toscaparser.elements.interfaces as ifaces
from toscaparser.elements.nodetype import NodeType
from toscaparser.elements.policytype import PolicyType
from toscaparser.tests.base import TestCase

compute_type = NodeType('tosca.nodes.Compute')
component_type = NodeType('tosca.nodes.SoftwareComponent')
network_type = NodeType('tosca.nodes.network.Network')
network_port_type = NodeType('tosca.nodes.network.Port')
webserver_type = NodeType('tosca.nodes.WebServer')
database_type = NodeType('tosca.nodes.Database')
artif_root_type = ArtifactTypeDef('tosca.artifacts.Root')
artif_file_type = ArtifactTypeDef('tosca.artifacts.File')
artif_bash_type = ArtifactTypeDef('tosca.artifacts.Implementation.Bash')
artif_python_type = ArtifactTypeDef('tosca.artifacts.Implementation.Python')
artif_container_docker_type = ArtifactTypeDef('tosca.artifacts.'
                                              'Deployment.Image.'
                                              'Container.Docker')
artif_vm_iso_type = ArtifactTypeDef('tosca.artifacts.'
                                    'Deployment.Image.VM.ISO')
artif_vm_qcow2_type = ArtifactTypeDef('tosca.artifacts.'
                                      'Deployment.Image.VM.QCOW2')
policy_root_type = PolicyType('tosca.policies.Root')
policy_placement_type = PolicyType('tosca.policies.Placement')
policy_scaling_type = PolicyType('tosca.policies.Scaling')
policy_update_type = PolicyType('tosca.policies.Update')
policy_performance_type = PolicyType('tosca.policies.Performance')
group_type = GroupType('tosca.groups.Root')


class ToscaDefTest(TestCase):
    def test_type(self):
        self.assertEqual(compute_type.type, "tosca.nodes.Compute")
        self.assertRaises(exception.InvalidTypeError, NodeType,
                          'tosca.nodes.Invalid')
        self.assertEqual(network_type.type, "tosca.nodes.network.Network")
        self.assertEqual(network_port_type.type, "tosca.nodes.network.Port")

    def test_parent_type(self):
        self.assertEqual(compute_type.parent_type.type, "tosca.nodes.Root")
        self.assertEqual(network_type.parent_type.type, "tosca.nodes.Root")
        self.assertEqual(network_port_type.parent_type.type,
                         "tosca.nodes.Root")

    def test_group(self):
        self.assertEqual(group_type.type, "tosca.groups.Root")
        self.assertIn(ifaces.LIFECYCLE_SHORTNAME, group_type.interfaces)

    def test_capabilities(self):
        # Assure the normative Compute node type
        # has all the required Capability types
        # regardless of symbloc name
        # TODO(Matt) - since Compute IS a normative node type
        # we SHOULD test symbolic capability names as well
        self.assertEqual(
            ['tosca.capabilities.Container',
             'tosca.capabilities.Node',
             'tosca.capabilities.OperatingSystem',
             'tosca.capabilities.Scalable',
             'tosca.capabilities.network.Bindable'],
            sorted([c.type for c in compute_type.get_capabilities_objects()]))
        # Assure the normative Network node type
        # hsa all the required Capability types
        # TODO(Matt) - since Network IS a normative node type
        # we SHOULD test symbolic capability names as well
        self.assertEqual(
            ['tosca.capabilities.Node',
             'tosca.capabilities.network.Linkable'],
            sorted([c.type for c in network_type.get_capabilities_objects()]))

        # Assure the normative WebServer node type's
        # Endpoint cap. has all required property names
        # Note: we are testing them in alphabetic sort order
        endpoint_props_def_objects = \
            self._get_capability_properties_def_objects(
                webserver_type.get_capabilities_objects(),
                'tosca.capabilities.Endpoint')
        # Assure WebServer's Endpoint capability's properties have their
        # required keyname value set correctly
        self.assertEqual(
            [('initiator', False), ('network_name', False), ('port', False),
             ('port_name', False), ('ports', False), ('protocol', True),
             ('secure', False), ('url_path', False)],
            sorted([(p.name, p.required) for p in endpoint_props_def_objects]))

        os_props = self._get_capability_properties_def_objects(
            compute_type.get_capabilities_objects(),
            'tosca.capabilities.OperatingSystem')
        self.assertEqual(
            [('architecture', False), ('distribution', False), ('type', False),
             ('version', False)],
            sorted([(p.name, p.required) for p in os_props]))

        host_props = self._get_capability_properties_def_objects(
            compute_type.get_capabilities_objects(),
            'tosca.capabilities.Container')
        self.assertEqual(
            [('cpu_frequency', False), ('disk_size', False),
             ('mem_size', False), ('num_cpus', False)],
            sorted([(p.name, p.required) for p in host_props]))
        endpoint_admin_properties = 'secure'
        endpoint_admin_props_def_objects = \
            self._get_capability_properties_def_objects(
                webserver_type.get_capabilities_objects(),
                'tosca.capabilities.Endpoint.Admin')
        self.assertIn(
            endpoint_admin_properties,
            sorted([p.name for p in endpoint_admin_props_def_objects]))

    def _get_capability_properties_def_objects(self, caps, type):
        properties_def = None
        for cap in caps:
            if cap.type == type:
                properties_def = cap.get_properties_def_objects()
                break
        return properties_def

    def _get_capability_properties_def(self, caps, type):
        properties_def = None
        for cap in caps:
            if cap.type == type:
                properties_def = cap.get_properties_def()
                break
        return properties_def

    def test_properties_def(self):
        self.assertEqual(
            ['name', 'password', 'port', 'user'],
            sorted(database_type.get_properties_def().keys()))

    def test_attributes_def(self):
        self.assertEqual(
            ['networks', 'ports', 'private_address', 'public_address',
             'state', 'tosca_id', 'tosca_name'],
            sorted(compute_type.get_attributes_def().keys()))

    def test_requirements(self):
        self.assertEqual(
            [{'host': {'capability': 'tosca.capabilities.Container',
                       'node': 'tosca.nodes.Compute',
                       'relationship': 'tosca.relationships.HostedOn'}},
             {'dependency': {'capability': 'tosca.capabilities.Node',
                             'node': 'tosca.nodes.Root',
                             'occurrences': [0, 'UNBOUNDED'],
                             'relationship': 'tosca.relationships.DependsOn'}}
             ],
            [r for r in component_type.requirements])

    def test_relationship(self):
        self.assertEqual(
            [('tosca.relationships.DependsOn', 'tosca.nodes.Root'),
             ('tosca.relationships.HostedOn', 'tosca.nodes.Compute')],
            sorted([(relation.type, node.type) for
                   relation, node in component_type.relationship.items()]))
        self.assertIn(
            ('tosca.relationships.HostedOn', ['tosca.capabilities.Container']),
            [(relation.type, relation.valid_target_types) for
             relation in list(component_type.relationship.keys())])
        self.assertIn(
            ('tosca.relationships.network.BindsTo', 'tosca.nodes.Compute'),
            [(relation.type, node.type) for
             relation, node in network_port_type.relationship.items()])
        self.assertIn(
            ('tosca.relationships.network.LinksTo',
             'tosca.nodes.network.Network'),
            [(relation.type, node.type) for
             relation, node in network_port_type.relationship.items()])

    def test_interfaces(self):
        self.assertEqual(compute_type.interfaces, None)
        root_node = NodeType('tosca.nodes.Root')
        self.assertIn(ifaces.LIFECYCLE_SHORTNAME, root_node.interfaces)

    def test_artifacts(self):
        self.assertEqual('tosca.artifacts.Root',
                         artif_file_type.parent_type)
        self.assertEqual({}, artif_file_type.parent_artifacts)
        self.assertEqual(sorted(['tosca.artifacts.Root'],
                                key=lambda x: str(x)),
                         sorted([artif_file_type.get_artifact(name)
                                for name in artif_file_type.defs],
                                key=lambda x: str(x)))

        self.assertEqual('tosca.artifacts.Implementation',
                         artif_bash_type.parent_type)
        self.assertEqual({'tosca.artifacts.Implementation':
                          {'derived_from': 'tosca.artifacts.Root',
                           'description':
                           'TOSCA base type for implementation artifacts'}},
                         artif_bash_type.parent_artifacts)
        self.assertEqual(sorted([['sh'], 'tosca.artifacts.Implementation',
                                 'Script artifact for the Unix Bash shell',
                                 'application/x-sh'], key=lambda x: str(x)),
                         sorted([artif_bash_type.get_artifact(name)
                                for name in artif_bash_type.defs],
                                key=lambda x: str(x)))

        self.assertEqual('tosca.artifacts.Implementation',
                         artif_python_type.parent_type)
        self.assertEqual({'tosca.artifacts.Implementation':
                          {'derived_from': 'tosca.artifacts.Root',
                           'description':
                           'TOSCA base type for implementation artifacts'}},
                         artif_python_type.parent_artifacts)
        self.assertEqual(sorted([['py'], 'tosca.artifacts.Implementation',
                                 'Artifact for the interpreted Python'
                                 ' language', 'application/x-python'],
                                key=lambda x: str(x)),
                         sorted([artif_python_type.get_artifact(name)
                                for name in artif_python_type.defs],
                                key=lambda x: str(x)))

        self.assertEqual('tosca.artifacts.Deployment.Image',
                         artif_container_docker_type.parent_type)
        self.assertEqual({'tosca.artifacts.Deployment':
                          {'derived_from': 'tosca.artifacts.Root',
                           'description':
                           'TOSCA base type for deployment artifacts'},
                          'tosca.artifacts.Deployment.Image':
                          {'derived_from': 'tosca.artifacts.Deployment'}},
                         artif_container_docker_type.parent_artifacts)
        self.assertEqual(sorted(['tosca.artifacts.Deployment.Image',
                                 'Docker container image'],
                                key=lambda x: str(x)),
                         sorted([artif_container_docker_type.
                                get_artifact(name) for name in
                                artif_container_docker_type.defs],
                                key=lambda x: str(x)))

        self.assertEqual('tosca.artifacts.Deployment.Image',
                         artif_vm_iso_type.parent_type)
        self.assertEqual({'tosca.artifacts.Deployment':
                          {'derived_from': 'tosca.artifacts.Root',
                           'description':
                           'TOSCA base type for deployment artifacts'},
                          'tosca.artifacts.Deployment.Image':
                          {'derived_from': 'tosca.artifacts.Deployment'}},
                         artif_vm_iso_type.parent_artifacts)
        self.assertEqual(sorted(['tosca.artifacts.Deployment.Image',
                                 'Virtual Machine (VM) image in '
                                 'ISO disk format',
                                 'application/octet-stream', ['iso']],
                                key=lambda x: str(x)),
                         sorted([artif_vm_iso_type.
                                get_artifact(name) for name in
                                artif_vm_iso_type.defs],
                                key=lambda x: str(x)))

        self.assertEqual('tosca.artifacts.Deployment.Image',
                         artif_vm_qcow2_type.parent_type)
        self.assertEqual({'tosca.artifacts.Deployment':
                          {'derived_from': 'tosca.artifacts.Root',
                           'description':
                           'TOSCA base type for deployment artifacts'},
                          'tosca.artifacts.Deployment.Image':
                          {'derived_from': 'tosca.artifacts.Deployment'}},
                         artif_vm_qcow2_type.parent_artifacts)
        self.assertEqual(sorted(['tosca.artifacts.Deployment.Image',
                                 'Virtual Machine (VM) image in QCOW v2 '
                                 'standard disk format',
                                 'application/octet-stream', ['qcow2']],
                                key=lambda x: str(x)),
                         sorted([artif_vm_qcow2_type.
                                get_artifact(name) for name in
                                artif_vm_qcow2_type.defs],
                                key=lambda x: str(x)))

    def test_policies(self):
        self.assertEqual('tosca.policies.Root',
                         policy_placement_type.parent_type)
        self.assertEqual({}, policy_placement_type.parent_policies)
        self.assertEqual(sorted(['tosca.policies.Root',
                                 'The TOSCA Policy Type definition that is '
                                 'used to govern placement of TOSCA nodes or '
                                 'groups of nodes.'],
                                key=lambda x: str(x)),
                         sorted([policy_placement_type.get_policy(name)
                                for name in policy_placement_type.defs],
                                key=lambda x: str(x)))

        self.assertEqual('tosca.policies.Root',
                         policy_scaling_type.parent_type)
        self.assertEqual({}, policy_scaling_type.parent_policies)
        self.assertEqual(sorted(['tosca.policies.Root',
                                 'The TOSCA Policy Type definition that is '
                                 'used to govern scaling of TOSCA nodes or '
                                 'groups of nodes.'],
                                key=lambda x: str(x)),
                         sorted([policy_scaling_type.get_policy(name)
                                for name in policy_scaling_type.defs],
                                key=lambda x: str(x)))

        self.assertEqual('tosca.policies.Root',
                         policy_update_type.parent_type)
        self.assertEqual({}, policy_update_type.parent_policies)
        self.assertEqual(sorted(['tosca.policies.Root',
                                 'The TOSCA Policy Type definition that is '
                                 'used to govern update of TOSCA nodes or '
                                 'groups of nodes.'],
                                key=lambda x: str(x)),
                         sorted([policy_update_type.get_policy(name)
                                for name in policy_update_type.defs],
                                key=lambda x: str(x)))

        self.assertEqual('tosca.policies.Root',
                         policy_performance_type.parent_type)
        self.assertEqual({}, policy_performance_type.parent_policies)
        self.assertEqual(sorted(['tosca.policies.Root',
                                 'The TOSCA Policy Type definition that is '
                                 'used to declare performance requirements '
                                 'for TOSCA nodes or groups of nodes.'],
                                key=lambda x: str(x)),
                         sorted([policy_performance_type.get_policy(name)
                                for name in policy_performance_type.defs],
                                key=lambda x: str(x)))

    def test_port_spec(self):
        tosca_def = EntityType.TOSCA_DEF
        port_spec = tosca_def.get('tosca.datatypes.network.PortSpec')
        self.assertEqual(port_spec.get('derived_from'),
                         'tosca.datatypes.Root')
        properties = port_spec.get('properties')
        self.assertEqual(
            sorted(['protocol', 'target', 'target_range', 'source',
                    'source_range']),
            sorted(properties.keys()))