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
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation 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:
def test_network(): from PetaSAN.core.cluster.network import Network net = Network() for i in net.get_node_interfaces(): print i.name, i.mac print len(net.get_node_interfaces())