def generate_l2(cls, cluster): res = { "base_mac": cluster.network_config.base_mac, "segmentation_type": cluster.network_config.segmentation_type, "phys_nets": { "physnet1": { "bridge": "br-ex", "vlan_range": None } } } if cluster.network_config.segmentation_type in \ (consts.NEUTRON_SEGMENT_TYPES.gre, consts.NEUTRON_SEGMENT_TYPES.tun): res["tunnel_id_ranges"] = utils.join_range( cluster.network_config.gre_id_range) elif cluster.network_config.segmentation_type == \ consts.NEUTRON_SEGMENT_TYPES.vlan: res["phys_nets"]["physnet2"] = { "bridge": "br-prv", "vlan_range": utils.join_range( cluster.network_config.vlan_range) } # Set non-default ml2 configurations attrs = Cluster.get_attributes(cluster).editable if 'neutron_mellanox' in attrs and \ attrs['neutron_mellanox']['plugin']['value'] == 'ethernet': res['mechanism_drivers'] = 'mlnx,openvswitch' seg_type = cluster.network_config.segmentation_type res['tenant_network_types'] = seg_type res['type_drivers'] = '{0},flat,local'.format(seg_type) return res
def generate_l2(cls, cluster): res = { "base_mac": cluster.network_config.base_mac, "segmentation_type": cluster.network_config.segmentation_type, "phys_nets": {"physnet1": {"bridge": "br-ex", "vlan_range": None}}, } if cluster.network_config.segmentation_type in ( consts.NEUTRON_SEGMENT_TYPES.gre, consts.NEUTRON_SEGMENT_TYPES.tun, ): res["tunnel_id_ranges"] = utils.join_range(cluster.network_config.gre_id_range) elif cluster.network_config.segmentation_type == consts.NEUTRON_SEGMENT_TYPES.vlan: res["phys_nets"]["physnet2"] = { "bridge": "br-prv", "vlan_range": utils.join_range(cluster.network_config.vlan_range), } # Set non-default ml2 configurations attrs = Cluster.get_attributes(cluster).editable if "neutron_mellanox" in attrs and attrs["neutron_mellanox"]["plugin"]["value"] == "ethernet": res["mechanism_drivers"] = "mlnx,openvswitch" seg_type = cluster.network_config.segmentation_type res["tenant_network_types"] = seg_type res["type_drivers"] = "{0},flat,local".format(seg_type) return res
def generate_l2(cls, cluster): res = { "base_mac": cluster.network_config.base_mac, "segmentation_type": cluster.network_config.segmentation_type, "phys_nets": { "physnet1": { "bridge": "br-ex", "vlan_range": None } } } if cluster.network_config.segmentation_type in \ (consts.NEUTRON_SEGMENT_TYPES.gre, consts.NEUTRON_SEGMENT_TYPES.tun): res["tunnel_id_ranges"] = utils.join_range( cluster.network_config.gre_id_range) elif cluster.network_config.segmentation_type == \ consts.NEUTRON_SEGMENT_TYPES.vlan: res["phys_nets"]["physnet2"] = { "bridge": "br-prv", "vlan_range": utils.join_range(cluster.network_config.vlan_range) } # Set non-default ml2 configurations attrs = Cluster.get_attributes(cluster).editable if 'neutron_mellanox' in attrs and \ attrs['neutron_mellanox']['plugin']['value'] == 'ethernet': res['mechanism_drivers'] = 'mlnx,openvswitch' seg_type = cluster.network_config.segmentation_type res['tenant_network_types'] = seg_type res['type_drivers'] = '{0},flat,local'.format(seg_type) return res
def generate_external_network( cls, cluster, multiple_floating_ranges=False): floating_ranges = [ netaddr.IPRange(r1, r2) for r1, r2 in cluster.network_config.floating_ranges ] floating_cidr, floating_gw = None, None networks = db().query( models.NetworkGroup.cidr, models.NetworkGroup.gateway ).join( models.NetworkGroup.nodegroup ).filter( models.NodeGroup.cluster_id == cluster.id ) for net in networks: if net[0] and floating_ranges[0] in netaddr.IPNetwork(net[0]): floating_cidr, floating_gw = net[0], net[1] break if multiple_floating_ranges: floating_ranges_rendered = [ utils.join_range(fr) for fr in cluster.network_config.floating_ranges] else: floating_ranges_rendered = utils.join_range( cluster.network_config.floating_ranges[0]) external_network = { "L3": { "subnet": floating_cidr, "gateway": floating_gw, "nameservers": [], "floating": floating_ranges_rendered, "enable_dhcp": False }, "L2": { "network_type": "flat", "segment_id": None, "router_ext": True, "physnet": "physnet1" }, "tenant": Cluster.get_creds(cluster)['tenant']['value'], "shared": False } return external_network
def _generate_external_network(cls, cluster): public_cidr, public_gw = db().query( NetworkGroup.cidr, NetworkGroup.gateway ).filter_by( group_id=Cluster.get_default_group(cluster).id, name='public' ).first() return { "L3": { "subnet": public_cidr, "gateway": public_gw, "nameservers": [], "floating": utils.join_range( cluster.network_config.floating_ranges[0]), "enable_dhcp": False }, "L2": { "network_type": "flat", "segment_id": None, "router_ext": True, "physnet": "physnet1" }, "tenant": Cluster.get_creds(cluster)['tenant']['value'], "shared": False }
def _generate_external_network(cls, cluster): public_cidr, public_gw = db().query( NetworkGroup.cidr, NetworkGroup.gateway).filter_by( group_id=Cluster.get_default_group(cluster).id, name='public').first() return { "L3": { "subnet": public_cidr, "gateway": public_gw, "nameservers": [], "floating": utils.join_range(cluster.network_config.floating_ranges[0]), "enable_dhcp": False }, "L2": { "network_type": "flat", "segment_id": None, "router_ext": True, "physnet": "physnet1" }, "tenant": Cluster.get_creds(cluster)['tenant']['value'], "shared": False }
def render_floating_ranges(cls, floating_ranges): """Renders floating IP ranges for external networks generator. :param floating_ranges: a list of strings :return: rendered string """ return utils.join_range(floating_ranges[0])
def generate_driver_information(cls, node, network_scheme, nm): network_mapping = network_scheme.get('roles', {}) endpoints = network_scheme.get('endpoints', {}) bonds_map = dict((b.name, b) for b in node.bond_interfaces) net_name_mapping = {'ex': 'public'} managed_networks = ['public', 'storage', 'management', 'private'] # Add interfaces drivers data for iface in node.nic_interfaces: if iface.driver or iface.bus_info: iface_dict = network_scheme['interfaces'][iface.name] if 'vendor_specific' not in iface_dict: iface_dict['vendor_specific'] = {} if iface.driver: iface_dict['vendor_specific']['driver'] = iface.driver if iface.bus_info: iface_dict['vendor_specific']['bus_info'] = iface.bus_info # Add physical allocation data for ngname, brname in six.iteritems(network_mapping): if ngname in net_name_mapping: ngname = net_name_mapping[ngname] if ngname not in managed_networks: continue if 'vendor_specific' not in endpoints[brname]: endpoints[brname]['vendor_specific'] = {} netgroup = nm.get_node_network_by_netname(node, ngname) ep_dict = endpoints[brname]['vendor_specific'] ep_dict['phy_interfaces'] = \ cls.get_phy_interfaces(bonds_map, netgroup) if netgroup['vlan'] > 1: ep_dict['vlans'] = netgroup['vlan'] if node.cluster.network_config.segmentation_type == \ consts.NEUTRON_SEGMENT_TYPES.vlan: private_ep = endpoints[network_mapping['neutron/private']] netgroup = nm.get_node_network_by_netname(node, 'private') phys = cls.get_phy_interfaces(bonds_map, netgroup) if 'vendor_specific' not in private_ep: private_ep['vendor_specific'] = {} private_ep['vendor_specific']['phy_interfaces'] = phys private_ep['vendor_specific']['vlans'] = utils.join_range( node.cluster.network_config.vlan_range) return network_scheme
def generate_driver_information(cls, node, network_scheme, nm, networks): network_mapping = network_scheme.get('roles', {}) endpoints = network_scheme.get('endpoints', {}) bonds_map = dict((b.name, b) for b in node.bond_interfaces) net_name_mapping = {'ex': 'public'} managed_networks = ['public', 'storage', 'management', 'private'] # Add interfaces drivers data for iface in node.nic_interfaces: if iface.driver or iface.bus_info: iface_dict = network_scheme['interfaces'][iface.name] if 'vendor_specific' not in iface_dict: iface_dict['vendor_specific'] = {} if iface.driver: iface_dict['vendor_specific']['driver'] = iface.driver if iface.bus_info: iface_dict['vendor_specific']['bus_info'] = iface.bus_info # Add physical allocation data for ngname, brname in six.iteritems(network_mapping): if ngname in net_name_mapping: ngname = net_name_mapping[ngname] if ngname not in managed_networks: continue if 'vendor_specific' not in endpoints[brname]: endpoints[brname]['vendor_specific'] = {} netgroup = nm.get_network_by_netname(ngname, networks) ep_dict = endpoints[brname]['vendor_specific'] ep_dict['phy_interfaces'] = \ cls.get_phy_interfaces(bonds_map, netgroup) if netgroup['vlan'] > 1: ep_dict['vlans'] = netgroup['vlan'] if node.cluster.network_config.segmentation_type == \ consts.NEUTRON_SEGMENT_TYPES.vlan: private_ep = endpoints[network_mapping['neutron/private']] netgroup = nm.get_network_by_netname('private', networks) phys = cls.get_phy_interfaces(bonds_map, netgroup) if 'vendor_specific' not in private_ep: private_ep['vendor_specific'] = {} private_ep['vendor_specific']['phy_interfaces'] = phys private_ep['vendor_specific']['vlans'] = utils.join_range( node.cluster.network_config.vlan_range) return network_scheme
def generate_driver_information(cls, node, network_scheme, nm, networks): network_mapping = network_scheme.get("roles", {}) endpoints = network_scheme.get("endpoints", {}) bonds_map = dict((b.name, b) for b in node.bond_interfaces) net_name_mapping = {"ex": "public"} managed_networks = ["public", "storage", "management", "private"] # Add interfaces drivers data for iface in node.nic_interfaces: if iface.driver or iface.bus_info: iface_dict = network_scheme["interfaces"][iface.name] if "vendor_specific" not in iface_dict: iface_dict["vendor_specific"] = {} if iface.driver: iface_dict["vendor_specific"]["driver"] = iface.driver if iface.bus_info: iface_dict["vendor_specific"]["bus_info"] = iface.bus_info # Add physical allocation data for ngname, brname in six.iteritems(network_mapping): if ngname in net_name_mapping: ngname = net_name_mapping[ngname] if ngname not in managed_networks: continue if "vendor_specific" not in endpoints[brname]: endpoints[brname]["vendor_specific"] = {} netgroup = nm.get_network_by_netname(ngname, networks) ep_dict = endpoints[brname]["vendor_specific"] ep_dict["phy_interfaces"] = cls.get_phy_interfaces(bonds_map, netgroup) if netgroup["vlan"] > 1: ep_dict["vlans"] = netgroup["vlan"] if node.cluster.network_config.segmentation_type == consts.NEUTRON_SEGMENT_TYPES.vlan: private_ep = endpoints[network_mapping["neutron/private"]] netgroup = nm.get_network_by_netname("private", networks) phys = cls.get_phy_interfaces(bonds_map, netgroup) if "vendor_specific" not in private_ep: private_ep["vendor_specific"] = {} private_ep["vendor_specific"]["phy_interfaces"] = phys private_ep["vendor_specific"]["vlans"] = utils.join_range(node.cluster.network_config.vlan_range) return network_scheme
def render_floating_ranges(cls, floating_ranges): return [utils.join_range(x) for x in floating_ranges]