Ejemplo n.º 1
0
    def get_default_network_to_endpoint_mapping(cls, node):
        mapping = {
            consts.NETWORKS.fuelweb_admin: 'br-fw-admin',
            consts.NETWORKS.storage: 'br-storage',
            consts.NETWORKS.management: 'br-mgmt',
            consts.NETWORKS.private: 'br-prv'}

        # roles can be assigned to br-ex only in case it has a public IP
        if Node.should_have_public_with_ip(node):
            mapping[consts.NETWORKS.public] = 'br-ex'

        return mapping
Ejemplo n.º 2
0
    def get_default_network_to_endpoint_mapping(cls, node):
        mapping = {
            consts.NETWORKS.fuelweb_admin: 'br-fw-admin',
            consts.NETWORKS.storage: 'br-storage',
            consts.NETWORKS.management: 'br-mgmt',
            consts.NETWORKS.private: 'br-prv'
        }

        # roles can be assigned to br-ex only in case it has a public IP
        if Node.should_have_public_with_ip(node):
            mapping[consts.NETWORKS.public] = 'br-ex'

        return mapping
Ejemplo n.º 3
0
 def update_nodes_net_info(cls, cluster, nodes):
     """Adds information about networks to each node."""
     for node in Cluster.get_nodes_not_for_deletion(cluster):
         netw_data = node.network_data
         addresses = {}
         for net in node.cluster.network_groups:
             if net.name == 'public' and \
                     not Node.should_have_public_with_ip(node):
                 continue
             if net.meta.get('render_addr_mask'):
                 addresses.update(
                     cls.get_addr_mask(netw_data, net.name,
                                       net.meta.get('render_addr_mask')))
         [n.update(addresses) for n in nodes if n['uid'] == str(node.uid)]
     return nodes
 def update_nodes_net_info(cls, cluster, nodes):
     """Adds information about networks to each node."""
     for node in Cluster.get_nodes_not_for_deletion(cluster):
         netw_data = node.network_data
         addresses = {}
         for net in node.cluster.network_groups:
             if net.name == 'public' and \
                     not Node.should_have_public_with_ip(node):
                 continue
             if net.meta.get('render_addr_mask'):
                 addresses.update(cls.get_addr_mask(
                     netw_data,
                     net.name,
                     net.meta.get('render_addr_mask')))
         [n.update(addresses) for n in nodes
             if n['uid'] == str(node.uid)]
     return nodes
    def get_network_to_endpoint_mapping(cls, node):
        mapping = {
            consts.NETWORKS.fuelweb_admin: 'br-fw-admin',
            consts.NETWORKS.storage: 'br-storage',
            consts.NETWORKS.management: 'br-mgmt'}

        # roles can be assigned to br-ex only in case it has a public IP
        if Node.should_have_public_with_ip(node):
            mapping[consts.NETWORKS.public] = 'br-ex'

        if node.cluster.network_config.segmentation_type in \
                (consts.NEUTRON_SEGMENT_TYPES.gre,
                 consts.NEUTRON_SEGMENT_TYPES.tun):
            mapping[consts.NETWORKS.private] = 'br-mesh'

        mapping.update(cls.get_node_non_default_bridge_mapping(node))
        return mapping
Ejemplo n.º 6
0
 def update_nodes_net_info(cls, cluster, nodes):
     """Adds information about networks to each node.
     This info is deprecated in 7.0 and should be removed in later version.
     """
     nm = Cluster.get_network_manager(cluster)
     for node in Cluster.get_nodes_not_for_deletion(cluster):
         netw_data = []
         for name, data in six.iteritems(nm.get_node_ips(node)):
             data['name'] = name
             netw_data.append(data)
         addresses = {}
         for net in node.cluster.network_groups:
             if net.name == 'public' and \
                     not Node.should_have_public_with_ip(node):
                 continue
             if net.meta.get('render_addr_mask'):
                 addresses.update(cls.get_addr_mask(
                     netw_data,
                     net.name,
                     net.meta.get('render_addr_mask')))
         [n.update(addresses) for n in nodes
          if n['uid'] == str(node.uid)]
     return nodes
    def generate_network_scheme(cls, node, networks):
        """Create a data structure and fill it with static values.

        :param node: instance of db.sqlalchemy.models.node.Node
        :param networks: list of networks data dicts
        :return: dict of network scheme attributes
        """
        attrs = {
            'version': '1.1',
            'provider': 'lnx',
            'interfaces': {},
            'endpoints': {},
            'roles': cls.get_network_role_mapping_to_interfaces(node),
        }

        is_public = Node.should_have_public(node)
        if is_public:
            attrs['endpoints']['br-ex'] = {'IP': 'none'}
            attrs['endpoints']['br-floating'] = {'IP': 'none'}
            attrs['roles']['ex'] = 'br-ex'
            attrs['roles']['neutron/floating'] = 'br-floating'

        nm = Cluster.get_network_manager(node.cluster)

        # Populate IP and GW information to endpoints.
        netgroup_mapping = (cls.get_network_to_endpoint_mapping(node)
                            .items())
        # get_network_to_endpoint_mapping() adds mapping for 'public' only in
        # case the node 'should_have_public_with_ip'. Here we need to add it
        # because proper transformations should be formed no matter if br-ex
        # has IP or not.
        public_mapping = (consts.NETWORKS.public, 'br-ex')
        if is_public and public_mapping not in netgroup_mapping:
            netgroup_mapping.append(public_mapping)

        if node.cluster.network_config.segmentation_type in \
                (consts.NEUTRON_SEGMENT_TYPES.gre,
                 consts.NEUTRON_SEGMENT_TYPES.tun):
            attrs['endpoints']['br-mesh'] = {}
            attrs['roles']['neutron/mesh'] = 'br-mesh'

        netgroups = {}
        nets_by_ifaces = defaultdict(list)
        for ngname, brname in netgroup_mapping:
            # Here we get a dict with network description for this particular
            # node with its assigned IPs and device names for each network.
            netgroup = nm.get_network_by_netname(ngname, networks)
            if netgroup.get('ip'):
                attrs['endpoints'][brname] = {'IP': [netgroup['ip']]}
            netgroups[ngname] = netgroup
            nets_by_ifaces[netgroup['dev']].append({
                'br_name': brname,
                'vlan_id': netgroup['vlan']
            })

        # Add gateway.
        if Node.should_have_public_with_ip(node):
            attrs['endpoints']['br-ex']['gateway'] = \
                netgroups['public']['gateway']
        else:
            gw = nm.get_default_gateway(node.id)
            attrs['endpoints']['br-fw-admin']['gateway'] = gw

        # Fill up interfaces.
        for iface in node.nic_interfaces:
            if iface.bond:
                attrs['interfaces'][iface.name] = {}
            else:
                attrs['interfaces'][iface.name] = \
                    nm.get_iface_properties(iface)

        # Dance around Neutron segmentation type.
        prv_base_ep = None
        if node.cluster.network_config.segmentation_type == \
                consts.NEUTRON_SEGMENT_TYPES.vlan:
            attrs['endpoints']['br-prv'] = {'IP': 'none'}
            attrs['roles']['neutron/private'] = 'br-prv'

            netgroup = nm.get_network_by_netname('private', networks)
            # create br-aux if there is no untagged network (endpoint) on the
            # same interface.
            if netgroup['dev'] in nets_by_ifaces:
                for ep in nets_by_ifaces[netgroup['dev']]:
                    if not ep['vlan_id']:
                        prv_base_ep = ep['br_name']
            if not prv_base_ep:
                nets_by_ifaces[netgroup['dev']].append({
                    'br_name': 'br-aux',
                    'vlan_id': None
                })

        attrs['transformations'] = cls.generate_transformations(
            node, nm, nets_by_ifaces, is_public, prv_base_ep)

        if NodeGroupCollection.get_by_cluster_id(
                node.cluster.id).count() > 1:
            cls.generate_routes(node, attrs, nm, netgroup_mapping, netgroups,
                                networks)

        attrs = cls.generate_driver_information(node, attrs, nm, networks)

        if node.cluster.network_config.segmentation_type in \
                (consts.NEUTRON_SEGMENT_TYPES.gre,
                 consts.NEUTRON_SEGMENT_TYPES.tun):
            attrs['roles'].pop('neutron/private', None)

        if node.cluster.network_config.segmentation_type == \
                consts.NEUTRON_SEGMENT_TYPES.vlan:
            attrs['roles'].pop('neutron/mesh', None)

        return attrs
Ejemplo n.º 8
0
    def generate_network_scheme(cls, node, networks):
        """Create a data structure and fill it with static values.

        :param node: instance of db.sqlalchemy.models.node.Node
        :param networks: list of networks data dicts
        :return: dict of network scheme attributes
        """
        attrs = {
            "version": "1.1",
            "provider": "lnx",
            "interfaces": {},
            "endpoints": {},
            "roles": cls.get_network_role_mapping_to_interfaces(node),
        }

        is_public = Node.should_have_public(node)
        if is_public:
            attrs["endpoints"]["br-ex"] = {"IP": "none"}
            attrs["endpoints"]["br-floating"] = {"IP": "none"}
            attrs["roles"]["ex"] = "br-ex"
            attrs["roles"]["neutron/floating"] = "br-floating"

        nm = Cluster.get_network_manager(node.cluster)

        # Populate IP and GW information to endpoints.
        netgroup_mapping = cls.get_network_to_endpoint_mapping(node).items()
        # get_network_to_endpoint_mapping() adds mapping for 'public' only in
        # case the node 'should_have_public_with_ip'. Here we need to add it
        # because proper transformations should be formed no matter if br-ex
        # has IP or not.
        public_mapping = (consts.NETWORKS.public, "br-ex")
        if is_public and public_mapping not in netgroup_mapping:
            netgroup_mapping.append(public_mapping)

        if node.cluster.network_config.segmentation_type in (
            consts.NEUTRON_SEGMENT_TYPES.gre,
            consts.NEUTRON_SEGMENT_TYPES.tun,
        ):
            attrs["endpoints"]["br-mesh"] = {}
            attrs["roles"]["neutron/mesh"] = "br-mesh"

        netgroups = {}
        nets_by_ifaces = defaultdict(list)
        for ngname, brname in netgroup_mapping:
            # Here we get a dict with network description for this particular
            # node with its assigned IPs and device names for each network.
            netgroup = nm.get_network_by_netname(ngname, networks)
            if netgroup.get("ip"):
                attrs["endpoints"][brname] = {"IP": [netgroup["ip"]]}
            netgroups[ngname] = netgroup
            nets_by_ifaces[netgroup["dev"]].append({"br_name": brname, "vlan_id": netgroup["vlan"]})

        # Add gateway.
        if Node.should_have_public_with_ip(node):
            attrs["endpoints"]["br-ex"]["gateway"] = netgroups["public"]["gateway"]
        else:
            gw = nm.get_default_gateway(node.id)
            attrs["endpoints"]["br-fw-admin"]["gateway"] = gw

        # Fill up interfaces.
        for iface in node.nic_interfaces:
            if iface.bond:
                attrs["interfaces"][iface.name] = {}
            else:
                attrs["interfaces"][iface.name] = nm.get_iface_properties(iface)

        # Dance around Neutron segmentation type.
        prv_base_ep = None
        if node.cluster.network_config.segmentation_type == consts.NEUTRON_SEGMENT_TYPES.vlan:
            attrs["endpoints"]["br-prv"] = {"IP": "none"}
            attrs["roles"]["neutron/private"] = "br-prv"

            netgroup = nm.get_network_by_netname("private", networks)
            # create br-aux if there is no untagged network (endpoint) on the
            # same interface.
            if netgroup["dev"] in nets_by_ifaces:
                for ep in nets_by_ifaces[netgroup["dev"]]:
                    if not ep["vlan_id"]:
                        prv_base_ep = ep["br_name"]
            if not prv_base_ep:
                nets_by_ifaces[netgroup["dev"]].append({"br_name": "br-aux", "vlan_id": None})

        attrs["transformations"] = cls.generate_transformations(node, nm, nets_by_ifaces, is_public, prv_base_ep)

        if NodeGroupCollection.get_by_cluster_id(node.cluster.id).count() > 1:
            cls.generate_routes(node, attrs, nm, netgroup_mapping, netgroups, networks)

        attrs = cls.generate_driver_information(node, attrs, nm, networks)

        if node.cluster.network_config.segmentation_type in (
            consts.NEUTRON_SEGMENT_TYPES.gre,
            consts.NEUTRON_SEGMENT_TYPES.tun,
        ):
            attrs["roles"].pop("neutron/private", None)

        if node.cluster.network_config.segmentation_type == consts.NEUTRON_SEGMENT_TYPES.vlan:
            attrs["roles"].pop("neutron/mesh", None)

        return attrs