def mellanox_settings(cls, node_attrs, node): """Serialize mellanox node attrs, then it will be merged with common attributes, if mellanox plugin or iSER storage enabled. """ # Get Mellanox data neutron_mellanox_data = \ Cluster.get_attributes(node.cluster).editable\ .get('neutron_mellanox', {}) # Get storage data storage_data = \ Cluster.get_attributes(node.cluster).editable.get('storage', {}) # Get network manager nm = Node.get_network_manager(node) # Init mellanox dict node_attrs['neutron_mellanox'] = {} # Find Physical port for VFs generation if 'plugin' in neutron_mellanox_data and \ neutron_mellanox_data['plugin']['value'] == 'ethernet': node_attrs = cls.set_mellanox_ml2_config(node_attrs, node, nm) # Fix network scheme to have physical port for RDMA if iSER enabled if 'iser' in storage_data and storage_data['iser']['value']: node_attrs = cls.fix_iser_port(node_attrs, node, nm) return node_attrs
def add_vlan_interfaces(cls, node): """Assign fixed_interfaces and vlan_interface. They should be equal. """ net_manager = Node.get_network_manager(node) fixed_interface = net_manager._get_interface_by_network_name( node.id, 'fixed') attrs = {'fixed_interface': fixed_interface.name, 'vlan_interface': fixed_interface.name} return attrs
def get_admin_ip_w_prefix(node): """Getting admin ip and assign prefix from admin network.""" network_manager = Node.get_network_manager(node) admin_ip = network_manager.get_admin_ip_for_node(node.id) admin_ip = IPNetwork(admin_ip) # Assign prefix from admin network admin_net = IPNetwork( network_manager.get_admin_network_group(node.id).cidr ) admin_ip.prefixlen = admin_net.prefixlen return str(admin_ip)
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'): net_manager = Node.get_network_manager(node) mgmt_cidr = net_manager.get_node_network_by_netname( node, 'management' )['ip'] attrs['management_vip'] = mgmt_cidr.split('/')[0] break return attrs
def generate_network_scheme(cls, node): attrs = super(NeutronNetworkDeploymentSerializer60, cls). \ generate_network_scheme(node) for item in attrs.get('transformations', ()): if 'tags' in item: item['vlan_ids'] = item['tags'] # Include information about all subnets that don't belong to this node. # This is used during deployment to configure routes to all other # networks in the environment. nm = Node.get_network_manager(node) other_nets = nm.get_networks_not_on_node(node) netgroup_mapping = [ ('storage', 'br-storage'), ('management', 'br-mgmt'), ('fuelweb_admin', 'br-fw-admin'), ] if Node.should_have_public(node): netgroup_mapping.append(('public', 'br-ex')) for ngname, brname in netgroup_mapping: netgroup = nm.get_node_network_by_netname(node, ngname) if netgroup.get('gateway'): attrs['endpoints'][brname]['gateway'] = netgroup['gateway'] attrs['endpoints'][brname]['other_nets'] = \ other_nets.get(ngname, []) if Node.should_have_public(node): attrs['endpoints']['br-ex']['default_gateway'] = True else: gw = nm.get_default_gateway(node.id) attrs['endpoints']['br-fw-admin']['gateway'] = gw attrs['endpoints']['br-fw-admin']['default_gateway'] = True return attrs
def generate_network_scheme(cls, node): # create network scheme structure and fill it with static values attrs = { 'version': '1.1', 'provider': 'lnx', 'interfaces': {}, 'endpoints': {}, 'roles': { 'fw-admin': 'br-fw-admin', 'storage': 'br-storage', 'management': 'br-mgmt', 'ex': 'br-ex', }, } netgroup_mapping = [ ('fuelweb_admin', 'br-fw-admin'), ('storage', 'br-storage'), ('management', 'br-mgmt'), ('public', 'br-ex'), ('fixed', '') # will be determined in code below ] nm = Node.get_network_manager(node) # populate IP address information to endpoints netgroups = {} nets_by_ifaces = defaultdict(list) fixed_sub_iface = None 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, ngname) if ngname == 'fixed': vlan_id = None if node.cluster.network_config.net_manager == \ consts.NOVA_NET_MANAGERS.FlatDHCPManager: vlan_id = \ node.cluster.network_config.fixed_networks_vlan_start net = {'vlan_id': vlan_id} fixed_sub_iface = cls.subiface_name(netgroup['dev'], net) attrs['endpoints'][fixed_sub_iface] = {'IP': 'none'} else: nets_by_ifaces[netgroup['dev']].append({ 'br_name': brname, 'vlan_id': netgroup['vlan'] }) if netgroup.get('ip'): attrs['endpoints'][brname] = {'IP': [netgroup['ip']]} netgroups[ngname] = netgroup attrs['endpoints']['br-ex']['gateway'] = \ netgroups['public']['gateway'] # add manager-related roles if node.cluster.network_config.net_manager == \ consts.NOVA_NET_MANAGERS.VlanManager: attrs['roles']['novanetwork/vlan'] = fixed_sub_iface else: attrs['roles']['novanetwork/fixed'] = fixed_sub_iface for iface in node.nic_interfaces: if iface.bond: attrs['interfaces'][iface.name] = {} else: attrs['interfaces'][iface.name] = \ nm.get_iface_properties(iface) attrs['transformations'] = \ cls.generate_transformations(node, nm, nets_by_ifaces, fixed_sub_iface) return attrs
def generate_network_scheme(cls, node): # Create a data structure and fill it with static values. attrs = { 'version': '1.1', 'provider': 'lnx', 'interfaces': {}, # It's a list of physical interfaces. 'endpoints': {}, 'roles': { 'management': 'br-mgmt', 'storage': 'br-storage', 'fw-admin': 'br-fw-admin', }, } is_public = Node.should_have_public(node) if is_public: attrs['endpoints']['br-ex'] = {} attrs['endpoints']['br-floating'] = {'IP': 'none'} attrs['roles']['ex'] = 'br-ex' attrs['roles']['neutron/floating'] = 'br-floating' nm = Node.get_network_manager(node) # Populate IP and GW information to endpoints. netgroup_mapping = [ ('storage', 'br-storage'), ('management', 'br-mgmt'), ('fuelweb_admin', 'br-fw-admin'), ] if is_public: netgroup_mapping.append(('public', 'br-ex')) if node.cluster.network_config.segmentation_type == 'gre': netgroup_mapping.append(('private', 'br-mesh')) 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_node_network_by_netname(node, ngname) 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 is_public: 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 == 'vlan': attrs['endpoints']['br-prv'] = {'IP': 'none'} attrs['roles']['neutron/private'] = 'br-prv' netgroup = nm.get_node_network_by_netname(node, 'private') # 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) attrs = cls.generate_driver_information(node, attrs, nm) 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-mgmt': {}, 'br-fw-admin': {}, }, 'roles': { 'management': 'br-mgmt', 'storage': 'br-storage', 'fw-admin': 'br-fw-admin', }, 'transformations': [] } if Node.should_have_public(node): attrs['endpoints']['br-ex'] = {} attrs['roles']['ex'] = 'br-ex' nm = Node.get_network_manager(node) iface_types = consts.NETWORK_INTERFACE_TYPES # Add a dynamic data to a structure. vlan_splinters_data = \ node.cluster.attributes.editable\ .get('vlan_splinters', {})\ # if vlan_splinters is enabled - use its value use_vlan_splinters = 'disabled' if vlan_splinters_data\ .get('metadata', {})\ .get('enabled'): use_vlan_splinters = \ vlan_splinters_data\ .get('vswitch', {})\ .get('value', 'disabled') # Fill up interfaces and add bridges for them. bonded_ifaces = [x for x in node.nic_interfaces if x.bond] for iface in node.interfaces: # Handle vlan splinters. if iface.type == iface_types.ether: attrs['interfaces'][iface.name] = { 'L2': cls._get_vlan_splinters_desc( use_vlan_splinters, iface, node.cluster ) } if iface in bonded_ifaces: continue attrs['transformations'].append({ 'action': 'add-br', 'name': 'br-%s' % iface.name }) if iface.type == iface_types.ether: attrs['transformations'].append({ 'action': 'add-port', 'bridge': 'br-%s' % iface.name, 'name': iface.name }) elif iface.type == iface_types.bond: attrs['transformations'].append({ 'action': 'add-bond', 'bridge': 'br-%s' % iface.name, 'name': iface.name, 'interfaces': [x['name'] for x in iface.slaves], 'properties': nm.get_ovs_bond_properties(iface) }) # Add bridges for networks. # We have to add them after br-ethXX bridges because it is the way # to provide a right ordering of ifdown/ifup operations with # IP interfaces. brnames = ['br-ex', 'br-mgmt', 'br-storage', 'br-fw-admin'] if not Node.should_have_public(node): brnames.pop(0) for brname in brnames: attrs['transformations'].append({ 'action': 'add-br', 'name': brname }) # Populate IP address information to endpoints. netgroup_mapping = [ ('storage', 'br-storage'), ('management', 'br-mgmt'), ('fuelweb_admin', 'br-fw-admin'), ] if Node.should_have_public(node): netgroup_mapping.append(('public', 'br-ex')) 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, ngname) if netgroup.get('ip'): attrs['endpoints'][brname]['IP'] = [netgroup['ip']] netgroups[ngname] = netgroup if Node.should_have_public(node): attrs['endpoints']['br-ex']['gateway'] = \ netgroups['public']['gateway'] else: attrs['endpoints']['br-fw-admin']['gateway'] = settings.MASTER_IP # Connect interface bridges to network bridges. for ngname, brname in netgroup_mapping: netgroup = nm.get_node_network_by_netname(node, 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.network_config.segmentation_type == 'vlan': attrs['endpoints']['br-prv'] = {'IP': 'none'} attrs['roles']['private'] = 'br-prv' attrs['transformations'].append({ 'action': 'add-br', 'name': '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.network_config.segmentation_type == 'gre': attrs['roles']['mesh'] = 'br-mgmt' return attrs