← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1682014] [NEW] network Renderer for rhel is unavailable when render bond/vlan interface.

 

Public bug reported:

In rhel, when use clodinit to config network from network_data.json, network renderer cann't work well when render bond or vlan.
In sysconfig renderer, '_render_bond_interfaces' method has a wrong logic when type is bond,there is no 'bond-master' in iface object. 	
apart from this, '_render_bond_interfaces' and '_render_vlan_interfaces' should also process _render_subnet too. IMO, this two method should like this:

    @classmethod
    def _render_bond_interfaces(cls, network_state, iface_contents):
        bond_filter = renderer.filter_by_type('bond')
        for iface in network_state.iter_interfaces(bond_filter):
            iface_name = iface['name']
            iface_cfg = iface_contents[iface_name]
            cls._render_bonding_opts(iface_cfg, iface)
            iface_subnets = iface.get("subnets", [])
            route_cfg = iface_cfg.routes
            if len(iface_subnets) == 1:
                cls._render_subnet(iface_cfg, route_cfg, iface_subnets[0])
            elif len(iface_subnets) > 1:
                for i, iface_subnet in enumerate(iface_subnets,
                                                 start=len(iface.children)):
                    iface_sub_cfg = iface_cfg.copy()
                    iface_sub_cfg.name = "%s:%s" % (iface_name, i)
                    iface.children.append(iface_sub_cfg)
                    cls._render_subnet(iface_sub_cfg, route_cfg, iface_subnet)
            master_cfgs = [iface_cfg]
            master_cfgs.extend(iface_cfg.children)
            for master_cfg in master_cfgs:
                master_cfg['BONDING_MASTER'] = True
                master_cfg.kind = 'bond'

    @classmethod
    def _render_vlan_interfaces(cls, network_state, iface_contents):
        vlan_filter = renderer.filter_by_type('vlan')
        for iface in network_state.iter_interfaces(vlan_filter):
            iface_name = iface['name']
            iface_cfg = iface_contents[iface_name]
            iface_cfg['VLAN'] = True
            iface_cfg['PHYSDEV'] = iface_name[:iface_name.rfind('.')]
            iface_subnets = iface.get("subnets", [])
            route_cfg = iface_cfg.routes
            if len(iface_subnets) == 1:
                cls._render_subnet(iface_cfg, route_cfg, iface_subnets[0])
            elif len(iface_subnets) > 1:
                for i, iface_subnet in enumerate(iface_subnets,
                                                 start=len(iface.children)):
                    iface_sub_cfg = iface_cfg.copy()
                    iface_sub_cfg.name = "%s:%s" % (iface_name, i)
                    iface.children.append(iface_sub_cfg)
                    cls._render_subnet(iface_sub_cfg, route_cfg, iface_subnet)

** Affects: cloud-init
     Importance: Undecided
         Status: New


** Tags: rhel+sysconfig

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to cloud-init.
https://bugs.launchpad.net/bugs/1682014

Title:
  network Renderer for rhel is unavailable when render bond/vlan
  interface.

Status in cloud-init:
  New

Bug description:
  In rhel, when use clodinit to config network from network_data.json, network renderer cann't work well when render bond or vlan.
  In sysconfig renderer, '_render_bond_interfaces' method has a wrong logic when type is bond,there is no 'bond-master' in iface object. 	
  apart from this, '_render_bond_interfaces' and '_render_vlan_interfaces' should also process _render_subnet too. IMO, this two method should like this:

      @classmethod
      def _render_bond_interfaces(cls, network_state, iface_contents):
          bond_filter = renderer.filter_by_type('bond')
          for iface in network_state.iter_interfaces(bond_filter):
              iface_name = iface['name']
              iface_cfg = iface_contents[iface_name]
              cls._render_bonding_opts(iface_cfg, iface)
              iface_subnets = iface.get("subnets", [])
              route_cfg = iface_cfg.routes
              if len(iface_subnets) == 1:
                  cls._render_subnet(iface_cfg, route_cfg, iface_subnets[0])
              elif len(iface_subnets) > 1:
                  for i, iface_subnet in enumerate(iface_subnets,
                                                   start=len(iface.children)):
                      iface_sub_cfg = iface_cfg.copy()
                      iface_sub_cfg.name = "%s:%s" % (iface_name, i)
                      iface.children.append(iface_sub_cfg)
                      cls._render_subnet(iface_sub_cfg, route_cfg, iface_subnet)
              master_cfgs = [iface_cfg]
              master_cfgs.extend(iface_cfg.children)
              for master_cfg in master_cfgs:
                  master_cfg['BONDING_MASTER'] = True
                  master_cfg.kind = 'bond'

      @classmethod
      def _render_vlan_interfaces(cls, network_state, iface_contents):
          vlan_filter = renderer.filter_by_type('vlan')
          for iface in network_state.iter_interfaces(vlan_filter):
              iface_name = iface['name']
              iface_cfg = iface_contents[iface_name]
              iface_cfg['VLAN'] = True
              iface_cfg['PHYSDEV'] = iface_name[:iface_name.rfind('.')]
              iface_subnets = iface.get("subnets", [])
              route_cfg = iface_cfg.routes
              if len(iface_subnets) == 1:
                  cls._render_subnet(iface_cfg, route_cfg, iface_subnets[0])
              elif len(iface_subnets) > 1:
                  for i, iface_subnet in enumerate(iface_subnets,
                                                   start=len(iface.children)):
                      iface_sub_cfg = iface_cfg.copy()
                      iface_sub_cfg.name = "%s:%s" % (iface_name, i)
                      iface.children.append(iface_sub_cfg)
                      cls._render_subnet(iface_sub_cfg, route_cfg, iface_subnet)

To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-init/+bug/1682014/+subscriptions


Follow ups