Beispiel #1
0
def test_actor_more_ethX(current_actor_context):
    pci1 = PCIAddress(domain="0000",
                      bus="3e",
                      function="00",
                      device="PCI bridge")
    pci2 = PCIAddress(domain="0000",
                      bus="3d",
                      function="00",
                      device="Serial controller")
    interface = [
        Interface(name="eth0",
                  mac="52:54:00:0b:4a:6d",
                  vendor="redhat",
                  driver="pcieport",
                  pci_info=pci1,
                  devpath="/devices/platform/usb/cdc-wdm0"),
        Interface(name="eth1",
                  mac="52:54:00:0b:4a:6a",
                  vendor="redhat",
                  driver="serial",
                  pci_info=pci2,
                  devpath="/devices/hidraw/hidraw0")
    ]
    current_actor_context.feed(PersistentNetNamesFacts(interfaces=interface))
    current_actor_context.run()
    assert current_actor_context.consume(Report)
    assert 'inhibitor' in current_actor_context.consume(
        Report)[0].report['flags']
def test_bz_1899455_crash_iface(monkeypatch, current_actor_context, adjust_cwd):
    """
    Cover situation when network device is discovered on the src sys but not
    inside the upgrade environment.

    This typically happens when the network device needs specific drivers which
    are not present inside the upgrade initramfs. Usually it points to a missing
    actors that should influence the upgrade initramfs in a way the drivers are
    installed. In this situation, only correct thing we can do in this actor
    is print warning / report that we couldn't located particular devices so
    we cannot handle interface names related to this devices.
    """
    with open(os.path.join(CUR_DIR, 'files/crashed_ifaces.json')) as fp:
        json_msgs = json.load(fp)
    msgs = [
        PersistentNetNamesFacts.create(json_msgs["PersistentNetNamesFacts"]),
        PersistentNetNamesFactsInitramfs.create(json_msgs["PersistentNetNamesFactsInitramfs"]),
    ]
    monkeypatch.setattr(persistentnetnamesconfig, 'generate_link_file', generate_link_file_mocked)
    monkeypatch.setattr(persistentnetnamesconfig.api, 'current_actor', CurrentActorMocked(msgs=msgs))
    monkeypatch.setattr(persistentnetnamesconfig.api, 'current_logger', logger_mocked())
    monkeypatch.setattr(persistentnetnamesconfig.api, 'produce', produce_mocked())
    persistentnetnamesconfig.process()

    for prod_models in [RenamedInterfaces, InitrdIncludes]:
        any(isinstance(i, prod_models) for i in persistentnetnamesconfig.api.produce.model_instances)
    assert any(['Some network devices' in x for x in persistentnetnamesconfig.api.current_logger.warnmsg])
def test_identical(current_actor_context):
    interfaces = generate_interfaces(4)
    current_actor_context.feed(PersistentNetNamesFacts(interfaces=interfaces))
    current_actor_context.feed(PersistentNetNamesFactsInitramfs(interfaces=interfaces))
    current_actor_context.run()

    renamed_interfaces = current_actor_context.consume(RenamedInterfaces)[0]
    initrd_files = current_actor_context.consume(InitrdIncludes)[0]
    assert not renamed_interfaces.renamed
    assert not initrd_files.files
def test_identical(current_actor_context):
    interfaces = generate_interfaces(4)
    current_actor_context.feed(PersistentNetNamesFacts(interfaces=interfaces))
    current_actor_context.feed(
        PersistentNetNamesFactsInitramfs(interfaces=interfaces))
    current_actor_context.run(config_model=mock_configs.CONFIG)

    renamed_interfaces = current_actor_context.consume(RenamedInterfaces)[0]
    initrd_files = current_actor_context.consume(InitrdIncludes)[0]
    t_initrafms_tasks = current_actor_context.consume(TargetInitramfsTasks)[0]
    assert initrd_files.files == t_initrafms_tasks.include_files
    assert not renamed_interfaces.renamed
    assert not t_initrafms_tasks.include_files
def test_renamed_single_noneth(monkeypatch, current_actor_context):
    monkeypatch.setattr(persistentnetnamesconfig, 'generate_link_file', generate_link_file_mocked)

    interfaces = generate_interfaces(4)
    current_actor_context.feed(PersistentNetNamesFacts(interfaces=interfaces))
    interfaces[0].name = 'n4'
    current_actor_context.feed(PersistentNetNamesFactsInitramfs(interfaces=interfaces))
    current_actor_context.run()

    renamed_interfaces = current_actor_context.consume(RenamedInterfaces)[0]
    initrd_files = current_actor_context.consume(InitrdIncludes)[0]
    assert not renamed_interfaces.renamed
    assert len(initrd_files.files) == 1
    assert '/etc/systemd/network/10-leapp-n0.link' in initrd_files.files
Beispiel #6
0
def test_actor_single_int_not_ethX(current_actor_context):
    pci = PCIAddress(domain="0000",
                     bus="3e",
                     function="00",
                     device="PCI bridge")
    interface = [
        Interface(name="tap0",
                  mac="52:54:00:0b:4a:60",
                  vendor="redhat",
                  driver="pcieport",
                  pci_info=pci,
                  devpath="/devices/platform/usb/cdc-wdm0")
    ]
    current_actor_context.feed(PersistentNetNamesFacts(interfaces=interface))
    current_actor_context.run()
    assert not current_actor_context.consume(Report)
def test_renamed_single_eth(monkeypatch, current_actor_context):
    monkeypatch.setattr(persistentnetnamesconfig, 'generate_link_file', generate_link_file_mocked)

    interfaces = generate_interfaces(4)
    for i in range(4):
        interfaces[i].name = 'eth{}'.format(i)
    current_actor_context.feed(PersistentNetNamesFacts(interfaces=interfaces))
    interfaces[0].name = 'eth4'
    current_actor_context.feed(PersistentNetNamesFactsInitramfs(interfaces=interfaces))
    current_actor_context.run()

    renamed_interfaces = current_actor_context.consume(RenamedInterfaces)[0]
    initrd_files = current_actor_context.consume(InitrdIncludes)[0]
    assert len(renamed_interfaces.renamed) == 1
    assert renamed_interfaces.renamed[0].rhel7_name == 'eth0'
    assert renamed_interfaces.renamed[0].rhel8_name == 'eth4'
    assert not initrd_files.files
def test_renamed_swap_noneth(monkeypatch, current_actor_context):
    monkeypatch.setattr(persistentnetnamesconfig, 'generate_link_file',
                        generate_link_file_mocked)

    interfaces = generate_interfaces(4)
    current_actor_context.feed(PersistentNetNamesFacts(interfaces=interfaces))
    interfaces[0].name = 'n3'
    interfaces[3].name = 'n0'
    current_actor_context.feed(
        PersistentNetNamesFactsInitramfs(interfaces=interfaces))
    current_actor_context.run()

    renamed_interfaces = current_actor_context.consume(RenamedInterfaces)[0]
    initrd_files = current_actor_context.consume(InitrdIncludes)[0]
    t_initrafms_tasks = current_actor_context.consume(TargetInitramfsTasks)[0]
    assert initrd_files.files == t_initrafms_tasks.include_files
    assert not renamed_interfaces.renamed
    assert len(t_initrafms_tasks.include_files) == 2
    assert '/etc/systemd/network/10-leapp-n0.link' in t_initrafms_tasks.include_files
    assert '/etc/systemd/network/10-leapp-n3.link' in t_initrafms_tasks.include_files
Beispiel #9
0
 def process(self):
     self.produce(
         PersistentNetNamesFacts(
             interfaces=list(persistentnetnames.interfaces())))