def create_bond_definition(nic_list, next_bond_num): slaves_list = [HostNic(id=nic.id) for nic in nic_list] if len(slaves_list) > 1: bonding = Bonding(options=[ Option(name=const.BOND_MODE_OPTION_NAME, value=const.BOND_MODE_OPTION_VALUE) ], slaves=slaves_list) bond_name = const.BOND_PREFIX + str(next_bond_num) logging.info('Creating bond %s with slaves: %s', bond_name, ', '.join([nic.name for nic in nic_list])) return HostNic(name=bond_name, bonding=bonding) else: return None
def create_attachment_definition(nic_list, next_bond_num, attachment_dict): attachments_list = [] bond_name = const.BOND_PREFIX + str(next_bond_num) for nic in nic_list: attachments = attachment_dict.get(nic, []) for attachment in attachments: attachment.host_nic = HostNic(name=bond_name) attachments_list.append(attachment) return attachments_list
def attach_network_to_host(host, nic_name, network_name, ip_configuration, bonds=[]): attachment = NetworkAttachment( network=Network(name=network_name), host_nic=HostNic(name=nic_name), ip_address_assignments=ip_configuration) return host.setup_networks( modified_bonds=bonds, modified_network_attachments=[attachment], check_connectivity=True)
def attach_network_to_host(host, nic_name, network_name, ip_configuration, bonds=[]): attachment = NetworkAttachment( network=Network(name=network_name), host_nic=HostNic(name=nic_name), ip_address_assignments=ip_configuration) testlib.assert_equals_within_short( lambda: _setup_host_networks_without_conflict( host=host, modified_bonds=bonds, modified_network_attachments=[attachment], check_connectivity=True), True, [])
def _bond_nics(number, host): slaves = [HostNic(name=nic) for nic in _host_vm_nics( # eth2, eth3 prefix, host.name, LIBVIRT_NETWORK_FOR_BONDING)] options = [ Option(name='mode', value='active-backup'), Option(name='miimon', value='200'), ] bond = HostNic( name=BOND_NAME, bonding=Bonding(slaves=slaves, options=options)) ip_configuration = network_utils_v4.create_static_ip_configuration( MIGRATION_NETWORK_IPv4_ADDR.format(number), MIGRATION_NETWORK_IPv4_MASK, MIGRATION_NETWORK_IPv6_ADDR.format(number), MIGRATION_NETWORK_IPv6_MASK) host_service = engine.hosts_service().host_service(id=host.id) network_utils_v4.attach_network_to_host( host_service, BOND_NAME, MIGRATION_NETWORK, ip_configuration, [bond])