def get_node_eths(self): net = Network() management = net.get_node_management_interface() eths = net.get_node_interfaces() for i in eths: if i.name == management: i.is_management = True break return eths
def is_valid_network_setting(self): config = configuration().get_cluster_info() net = Network() eths = net.get_node_interfaces() try: if config.eth_count != len(eths): return False elif config.management_eth_name != net.get_node_management_interface( ): return False else: return True except Exception as ex: logger.exception(ex.message) return False
def set_cluster_network_info(self, cluster_info): """ :type cluster_info: ClusterInfo """ try: config = configuration() net = Network() current_cluster_info = config.get_cluster_info() cluster_info.name = current_cluster_info.name cluster_info.bonds = current_cluster_info.bonds cluster_info.jumbo_frames = current_cluster_info.jumbo_frames cluster_info.eth_count = len(net.get_node_interfaces()) cluster_info.management_eth_name = net.get_node_management_interface( ) config.set_cluster_network_info(cluster_info) logger.info("Updated cluster network successfully.") except Exception as ex: logger.exception(ex.message) return Status().error return Status().done
''' from PetaSAN.core.common.enums import BondMode import sys from PetaSAN.core.cluster.configuration import configuration from PetaSAN.core.cluster.network import Network from PetaSAN.core.common.cmd import * logger.debug("Loading network configurations.") network = Network() config = configuration() node = config.get_node_info() cluster = config.get_cluster_info() node_management_eth_name = network.get_node_management_interface() node_management_vlan_id = network.get_node_management_vlan_id() node_management_eth_ip = network.get_node_management_ip() node_management_eth_netmask = network.get_node_management_netmask() gateway = Network().get_def_gateway() bonds = config.get_cluster_bonds() jumbo_eths = [] if hasattr(configuration().get_cluster_info(), "jumbo_frames"): jumbo_eths = config.get_cluster_info().jumbo_frames def create_bond(bond): if call_cmd("echo +{} > /sys/class/net/bonding_masters".format(bond.name)): # logger.debug("echo +{} > /sys/class/net/bonding_masters".format(bond.name)) if call_cmd("echo {} > /sys/class/net/{}/bonding/mode".format(bond.mode, bond.name)):
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. ''' from PetaSAN.core.cluster.network import Network from PetaSAN.core.cluster.configuration import configuration config = configuration().get_cluster_info() net = Network() eths = net.get_node_interfaces() print('cluster management interface ' + config.management_eth_name) print('node management interface ' + net.get_node_management_interface()) if config.management_eth_name == net.get_node_management_interface(): print('management interface match') else: print('Error: management interface mis-match !!') print('cluster eth count ' + str(config.eth_count)) print('node eth count ' + str(len(eths))) if config.eth_count == len(eths): print('eth count match') else: print('Error: eth count mis-match !!') print('detected interfaces')
def test_network_management(): from PetaSAN.core.cluster.network import Network net = Network() print net.get_node_management_interface()