Ejemplo n.º 1
0
    def network_provider_cluster_attrs(cls, cluster):
        """Cluster attributes."""
        attrs = {
            'quantum': True,
            'quantum_settings': cls.neutron_attrs(cluster)
        }

        if cluster.mode == 'multinode':
            for node in cluster.nodes:
                if cls._node_has_role_by_name(node, 'controller'):
                    mgmt_cidr = NetworkManager.get_node_network_by_netname(
                        node.id, 'management')['ip']
                    attrs['management_vip'] = mgmt_cidr.split('/')[0]
                    break

        return attrs
Ejemplo n.º 2
0
    def network_provider_cluster_attrs(cls, cluster):
        """Cluster attributes."""
        attrs = {'quantum': True,
                 'quantum_settings': cls.neutron_attrs(cluster)}

        if cluster.mode == 'multinode':
            for node in cluster.nodes:
                if cls._node_has_role_by_name(node, 'controller'):
                    mgmt_cidr = NetworkManager.get_node_network_by_netname(
                        node.id,
                        'management'
                    )['ip']
                    attrs['management_vip'] = mgmt_cidr.split('/')[0]
                    break

        return attrs
Ejemplo n.º 3
0
    def serialize_cluster_attrs(cls, cluster):
        """Cluster attributes."""
        attrs = cluster.attributes.merged_attrs_values()
        attrs['deployment_mode'] = cluster.mode
        attrs['deployment_id'] = cluster.id
        attrs['master_ip'] = settings.MASTER_IP
        cls.deep_merge(attrs['quantum_settings'], cls.neutron_attrs(cluster))
        attrs['quantum'] = True

        if cluster.mode == 'multinode':
            nm = NetworkManager()
            for node in cluster.nodes:
                if cls._node_has_role_by_name(node, 'controller'):
                    mgmt_cidr = nm.get_node_network_by_netname(
                        node.id,
                        'management'
                    )['ip']
                    attrs['management_vip'] = mgmt_cidr.split('/')[0]
                    break

        return attrs
Ejemplo n.º 4
0
    def serialize_cluster_attrs(cls, cluster):
        """Cluster attributes."""
        attrs = cluster.attributes.merged_attrs_values()
        attrs['deployment_mode'] = cluster.mode
        attrs['deployment_id'] = cluster.id
        attrs['master_ip'] = settings.MASTER_IP
        cls.deep_merge(attrs['quantum_settings'], cls.neutron_attrs(cluster))
        attrs['quantum'] = True

        if cluster.mode == 'multinode':
            nm = NetworkManager()
            for node in cluster.nodes:
                if cls._node_has_role_by_name(node, 'controller'):
                    mgmt_cidr = nm.get_node_network_by_netname(
                        node.id, 'management')['ip']
                    attrs['management_vip'] = mgmt_cidr.split('/')[0]
                    break

        attrs.update(cls.network_ranges(cluster))

        return attrs
    def generate_network_scheme(cls, node):

        # Create a data structure and fill it with static values.

        attrs = {
            'version': '1.0',
            'provider': 'ovs',
            'interfaces': {},  # It's a list of physical interfaces.
            'endpoints': {
                'br-storage': {},
                'br-ex': {},
                'br-mgmt': {},
                # There should be an endpoint for a fw-admin network.
            },
            'roles': {
                'ex': 'br-ex',
                'management': 'br-mgmt',
                'storage': 'br-storage',
                'fw-admin': ''
            },
            'transformations': []
        }
        # Add bridges for networks.
        for brname in ('br-ex', 'br-mgmt', 'br-storage', 'br-prv'):
            attrs['transformations'].append({
                'action': 'add-br',
                'name': brname
            })

        # Add a dynamic data to a structure.

        # Fill up interfaces and add bridges for them.
        for iface in node.interfaces:
            attrs['interfaces'][iface.name] = {}
            if iface.name == node.admin_interface.name:
                # A physical interface for the FuelWeb admin network should
                # not be used through bridge. Directly only.
                continue
            attrs['transformations'].append({
                'action': 'add-br',
                'name': 'br-%s' % iface.name
            })
            attrs['transformations'].append({
                'action': 'add-port',
                'bridge': 'br-%s' % iface.name,
                'name': iface.name
            })

        nm = NetworkManager()
        # Populate IP address information to endpoints.
        netgroup_mapping = [
            ('storage', 'br-storage'),
            ('public', 'br-ex'),
            ('management', 'br-mgmt')
        ]
        netgroups = {}
        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_node_network_by_netname(node.id, ngname)
            attrs['endpoints'][brname]['IP'] = [netgroup['ip']]
            netgroups[ngname] = netgroup
        attrs['endpoints']['br-ex']['gateway'] = netgroups['public']['gateway']

        # Connect interface bridges to network bridges.
        for ngname, brname in netgroup_mapping:
            netgroup = nm.get_node_network_by_netname(node.id, ngname)
            if not netgroup['vlan']:
                # Untagged network.
                attrs['transformations'].append({
                    'action': 'add-patch',
                    'bridges': ['br-%s' % netgroup['dev'], brname],
                    'trunks': [0]
                })
            elif netgroup['vlan'] > 1:
                # Tagged network.
                attrs['transformations'].append({
                    'action': 'add-patch',
                    'bridges': ['br-%s' % netgroup['dev'], brname],
                    'tags': [netgroup['vlan'], 0]
                })
            else:
                # FIXME! Should raise some exception I think.
                logger.error('Invalid vlan for network: %s' % str(netgroup))

        # Dance around Neutron segmentation type.
        if node.cluster.net_segment_type == 'vlan':
            attrs['endpoints']['br-prv'] = {'IP': 'none'}
            attrs['roles']['private'] = 'br-prv'

            attrs['transformations'].append({
                'action': 'add-patch',
                'bridges': [
                    'br-%s' % nm.get_node_interface_by_netname(
                        node.id,
                        'private'
                    ).name,
                    'br-prv'
                ]
            })
        elif node.cluster.net_segment_type == 'gre':
            attrs['roles']['mesh'] = 'br-mgmt'
        else:
            # FIXME! Should raise some exception I think.
            logger.error(
                'Invalid Neutron segmentation type: %s' %
                node.cluster.net_segment_type
            )

        # Fill up all about fuelweb-admin network.
        attrs['endpoints'][node.admin_interface.name] = {
            "IP": [cls.get_admin_ip(node)]
        }
        attrs['roles']['fw-admin'] = node.admin_interface.name

        return attrs
Ejemplo n.º 6
0
    def generate_network_scheme(cls, node):

        # Create a data structure and fill it with static values.

        attrs = {
            'version': '1.0',
            'provider': 'ovs',
            'interfaces': {},  # It's a list of physical interfaces.
            'endpoints': {
                'br-storage': {},
                'br-ex': {},
                'br-mgmt': {},
                # There should be an endpoint for a fw-admin network.
            },
            'roles': {
                'ex': 'br-ex',
                'management': 'br-mgmt',
                'storage': 'br-storage',
                'fw-admin': ''
            },
            'transformations': []
        }
        # Add bridges for networks.
        for brname in ('br-ex', 'br-mgmt', 'br-storage', 'br-prv'):
            attrs['transformations'].append({
                'action': 'add-br',
                'name': brname
            })

        # Add a dynamic data to a structure.

        # Fill up interfaces and add bridges for them.
        for iface in node.interfaces:
            attrs['interfaces'][iface.name] = {}
            if iface.name == node.admin_interface.name:
                # A physical interface for the FuelWeb admin network should
                # not be used through bridge. Directly only.
                continue
            attrs['transformations'].append({
                'action': 'add-br',
                'name': 'br-%s' % iface.name
            })
            attrs['transformations'].append({
                'action': 'add-port',
                'bridge': 'br-%s' % iface.name,
                'name': iface.name
            })

        nm = NetworkManager()
        # Populate IP address information to endpoints.
        netgroup_mapping = [('storage', 'br-storage'), ('public', 'br-ex'),
                            ('management', 'br-mgmt')]
        netgroups = {}
        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_node_network_by_netname(node.id, ngname)
            attrs['endpoints'][brname]['IP'] = [netgroup['ip']]
            netgroups[ngname] = netgroup
        attrs['endpoints']['br-ex']['gateway'] = netgroups['public']['gateway']

        # Connect interface bridges to network bridges.
        for ngname, brname in netgroup_mapping:
            netgroup = nm.get_node_network_by_netname(node.id, ngname)
            if not netgroup['vlan']:
                # Untagged network.
                attrs['transformations'].append({
                    'action':
                    'add-patch',
                    'bridges': ['br-%s' % netgroup['dev'], brname],
                    'trunks': [0]
                })
            elif netgroup['vlan'] > 1:
                # Tagged network.
                attrs['transformations'].append({
                    'action':
                    'add-patch',
                    'bridges': ['br-%s' % netgroup['dev'], brname],
                    'tags': [netgroup['vlan'], 0]
                })
            else:
                # FIXME! Should raise some exception I think.
                logger.error('Invalid vlan for network: %s' % str(netgroup))

        # Dance around Neutron segmentation type.
        if node.cluster.net_segment_type == 'vlan':
            attrs['endpoints']['br-prv'] = {'IP': 'none'}
            attrs['roles']['private'] = 'br-prv'

            attrs['transformations'].append({
                'action':
                'add-patch',
                'bridges': [
                    'br-%s' %
                    nm.get_node_interface_by_netname(node.id, 'private').name,
                    'br-prv'
                ]
            })
        elif node.cluster.net_segment_type == 'gre':
            attrs['roles']['mesh'] = 'br-mgmt'
        else:
            # FIXME! Should raise some exception I think.
            logger.error('Invalid Neutron segmentation type: %s' %
                         node.cluster.net_segment_type)

        # Fill up all about fuelweb-admin network.
        attrs['endpoints'][node.admin_interface.name] = {
            "IP": [cls.get_admin_ip(node)]
        }
        attrs['roles']['fw-admin'] = node.admin_interface.name

        return attrs