コード例 #1
0
ファイル: task.py プロジェクト: anbangr/fuel-web
    def get_config(cls, cluster):
        urls = objects.Cluster.get_repo_urls(cluster)
        nodes = []
        errors = []
        # if there is nothing to verify - just skip this task
        if not urls:
            return

        all_public = \
            objects.Cluster.should_assign_public_to_all_nodes(cluster)

        public_networks = filter(
            lambda ng: ng.name == 'public', cluster.network_groups)

        for public in public_networks:
            # we are not running this verification for nodes not in discover
            # state
            nodes_with_public_ip = []
            required_ips = 0
            group_nodes = objects.NodeCollection.filter_by(
                None, group_id=public.group_id,
                status=consts.NODE_STATUSES.discover).all()

            for node in group_nodes:

                if not (all_public or
                        objects.Node.should_have_public_with_ip(node)):
                    continue

                ip = NetworkManager.get_ip_by_network_name(node, public.name)
                nodes_with_public_ip.append((node, ip))
                if ip is None:
                    required_ips += 1

            if not nodes_with_public_ip:
                continue

            # we are not doing any allocations during verification
            # just ask for free ips and use them
            free_ips = iter(NetworkManager.get_free_ips(public, required_ips))
            mask = public.cidr.split('/')[1]

            lacp_modes = (
                consts.BOND_MODES.lacp_balance_tcp,
                consts.BOND_MODES.l_802_3ad)

            for node, ip in nodes_with_public_ip:
                if not node.online:
                    continue

                iface = NetworkManager.find_nic_assoc_with_ng(
                    node, public)

                if iface.bond and iface.bond.mode in lacp_modes:
                    errors.append(
                        'Iface {0} on node {1} configured to use '
                        'lacp-balance-tcp mode as part of {2}. Repo '
                        'availability verification for this node '
                        'will be skipped.'.format(
                            iface.name, node.name, iface.bond.name))
                    continue

                ip = ip or next(free_ips)
                node_config = {
                    'addr': '{0}/{1}'.format(ip, mask),
                    'gateway': public.gateway,
                    'vlan': public.vlan_start or 0,
                    'iface': iface.name,
                    'urls': urls,
                    'uid': node.uid}
                nodes.append(node_config)
        # if no nodes will be present - we will skip this task
        return nodes, errors
コード例 #2
0
ファイル: task.py プロジェクト: nebril/fuel-web
    def get_config(cls, cluster):
        urls = objects.Cluster.get_repo_urls(cluster)
        nodes = []
        errors = []
        # if there is nothing to verify - just skip this task
        if not urls:
            return

        all_public = \
            objects.Cluster.should_assign_public_to_all_nodes(cluster)

        public_networks = filter(lambda ng: ng.name == 'public',
                                 cluster.network_groups)

        for public in public_networks:
            # we are not running this verification for nodes not in discover
            # state
            nodes_with_public_ip = []
            required_ips = 0
            group_nodes = objects.NodeCollection.filter_by(
                None,
                group_id=public.group_id,
                status=consts.NODE_STATUSES.discover).all()

            for node in group_nodes:

                if not (all_public or objects.Node.should_have_public(node)):
                    continue

                ip = NetworkManager.get_ip_by_network_name(node, public.name)
                nodes_with_public_ip.append((node, ip))
                if ip is None:
                    required_ips += 1

            if not nodes_with_public_ip:
                continue

            # we are not doing any allocations during verification
            # just ask for free ips and use them
            free_ips = iter(NetworkManager.get_free_ips(public, required_ips))
            mask = public.cidr.split('/')[1]

            lacp_modes = (consts.BOND_MODES.lacp_balance_tcp,
                          consts.BOND_MODES.l_802_3ad)

            for node, ip in nodes_with_public_ip:
                if not node.online:
                    continue

                iface = NetworkManager.find_nic_assoc_with_ng(node, public)

                if iface.bond and iface.bond.mode in lacp_modes:
                    errors.append('Iface {0} on node {1} configured to use '
                                  'lacp-balance-tcp mode as part of {2}. Repo '
                                  'availability verification for this node '
                                  'will be skipped.'.format(
                                      iface.name, node.name, iface.bond.name))
                    continue

                ip = ip or next(free_ips)
                node_config = {
                    'addr': '{0}/{1}'.format(ip, mask),
                    'gateway': public.gateway,
                    'vlan': public.vlan_start or 0,
                    'iface': iface.name,
                    'urls': urls,
                    'uid': node.uid
                }
                nodes.append(node_config)
        # if no nodes will be present - we will skip this task
        return nodes, errors