def create_iface(iface_model, iface_source, **kwargs): """ Create an interface to be attached to vm :param iface_model: model of the interface device :param iface_source: source of the interface device :param kwargs: other k-w args that needed to create device :return: the newly created interface object """ iface = Interface('network') iface.model = iface_model iface.source = eval(iface_source) if 'mac' in kwargs: iface.mac_address = kwargs['mac'] else: mac = utils_net.generate_mac_address_simple() iface.mac_address = mac if 'address' in kwargs: iface.address = iface.new_iface_address( attrs=eval(kwargs['address'])) logging.debug('iface: %s', iface) return iface
def prepare_iface_xml(iface_bus, iface_slot): """ Create interface xml file """ iface_xml = Interface(type_name='bridge') iface_xml.source = {'bridge': 'virbr0'} iface_xml.model = "virtio" addr_dict = { 'bus': iface_bus, 'slot': iface_slot, 'domain': '0x0000', 'function': '0x0' } iface_xml.address = iface_xml.new_iface_address(type_name='pci', **{"attrs": addr_dict}) return iface_xml
def create_iface(iface_model, iface_source, **kwargs): """ Create an interface to be attached to vm :param iface_model: model of the interface device :param iface_source: source of the interface device :param kwargs: other k-w args that needed to create device :return: the newly created interface object """ iface = Interface('network') iface.model = iface_model iface.source = eval(iface_source) if 'mac' in kwargs: iface.mac_address = kwargs['mac'] else: mac = utils_net.generate_mac_address_simple() iface.mac_address = mac if 'address' in kwargs: iface.address = iface.new_iface_address(attrs=eval(kwargs['address'])) logging.debug('iface: %s', iface) return iface