def _ensure_iface_up(self, iface): if netinfo.operstate(iface) != 'up': _, err, rc = run_command(['ip', 'link', 'set', 'dev', iface, 'up']) if rc != 0: raise OperationFailed("KCHNET0020E", {'iface': iface, 'err': err}) # Add a delay to wait for the link change takes into effect. for i in range(10): time.sleep(1) if netinfo.operstate(iface) == 'up': break else: raise OperationFailed("KCHNET0021E", {'iface': iface})
def validate_bond_for_vlan(self, parent_iface): """ method to validate in the case of VLANs over bonds, it is important that the bond has slaves and that they are up, and vlan can not be configured over bond with the fail_over_mac=follow option. :param parent_iface: """ if encode_value(parent_iface) in ethtool.get_devices(): try: with open(FAIL_OVER_MAC % parent_iface) as dev_file: fail_over_mac = dev_file.readline().strip() except IOError: fail_over_mac = "n/a" if fail_over_mac == "follow 2": raise OperationFailed("GINNET0046E") else: """TODO: Need an investigation on, if parent of type bond is not active whether we can still create vlan interface or not. If 'yes', then can include code to validate the fail_over_mac in ifcfg persistant file""" wok_log.error("Parent interface of type 'Bond' is not active") raise OperationFailed("GINNET0051E") cfgdata = CfginterfaceModel().get_cfginterface_info(parent_iface) cfgInterfacesHelper.validate_dict_bond_for_vlan(cfgdata) slave_list = cfgdata[BASIC_INFO][BONDINFO][SLAVES] if len(slave_list) != 0: active_slave_found = True for slave in slave_list: # Fix ginger issue #144 if netinfo.operstate(slave) == STATE_DOWN: active_slave_found = False else: active_slave_found = True wok_log.info("One active slave is found:" + slave) break if (not active_slave_found): raise OperationFailed("GINNET0047E") else: wok_log.error("Minimum one slave has to be given for the bond") raise OperationFailed("GINNET0037E") return
def validate_bond_for_vlan(self, parent_iface): """ method to validate in the case of VLANs over bonds, it is important that the bond has slaves and that they are up, and vlan can not be configured over bond with the fail_over_mac=follow option. :param parent_iface: """ if encode_value(parent_iface) in ethtool.get_devices(): try: with open(FAIL_OVER_MAC % parent_iface) as dev_file: fail_over_mac = dev_file.readline().strip() except IOError: fail_over_mac = "n/a" if fail_over_mac == "follow 2": raise OperationFailed("GINNET0046E") else: """TODO: Need an investigation on, if parent of type bond is not active whether we can still create vlan interface or not. If 'yes', then can include code to validate the fail_over_mac in ifcfg persistant file""" raise OperationFailed("GINNET0051E") cfgdata = CfginterfaceModel().get_cfginterface_info(parent_iface) cfgInterfacesHelper.validate_dict_bond_for_vlan(cfgdata) slave_list = cfgdata[BASIC_INFO][BONDINFO][SLAVES] if len(slave_list) != 0: active_slave_found = True for slave in slave_list: # Fix ginger issue #144 if netinfo.operstate(slave) == STATE_DOWN: active_slave_found = False else: active_slave_found = True wok_log.info("One active slave is found:" + slave) break if (not active_slave_found): raise OperationFailed("GINNET0047E") else: raise OperationFailed("GINNET0037E") return