Exemplo n.º 1
0
def _attach_vm_network_to_host_static_config(api, network_name, host_num):
    engine = api.system_service()

    host = test_utils.hosts_in_cluster_v4(engine, CLUSTER_NAME)[host_num]
    host_service = engine.hosts_service().host_service(id=host.id)

    nic_name = backend.default_backend().ifaces_for(host.name,
                                                    network_name)[0]  # eth0
    ip_configuration = network_utils_v4.create_static_ip_configuration(
        VM_NETWORK_IPv4_ADDR.format(host_num + 1), VM_NETWORK_IPv4_MASK,
        VM_NETWORK_IPv6_ADDR.format(host_num + 1), VM_NETWORK_IPv6_MASK)

    network_utils_v4.attach_network_to_host(host_service, nic_name, VM_NETWORK,
                                            ip_configuration)

    host_nic = next(
        nic for nic in host_service.nics_service().list()
        if nic.name == '{}.{}'.format(nic_name, VM_NETWORK_VLAN_ID))

    assert (ipaddress.ip_address(host_nic.ip.address) == ipaddress.ip_address(
        VM_NETWORK_IPv4_ADDR.format(host_num + 1)))

    assert (ipaddress.ip_address(
        host_nic.ipv6.address) == ipaddress.ip_address(
            VM_NETWORK_IPv6_ADDR.format(host_num + 1)))
Exemplo n.º 2
0
def get_ips(ansible_facts, network_name):
    hostname = ansible_facts.get("ansible_hostname")
    ifaces = backend.default_backend().ifaces_for(hostname, network_name)
    ips = [
        ansible_facts.get("ansible_{}.ipv4.address".format(iface))
        for iface in ifaces
    ]
    return ips
Exemplo n.º 3
0
def module_mapper_for(host_pattern):
    inventory = backend.default_backend().ansible_inventory()
    # lago inventory uses short domain names, not FQDN.
    # In HE suites, host-0 is deployed with its FQDN, and this
    # is what the engine returns to us when asking which host
    # runs some VM. So when we feed this answer from the engine
    # to current function, strip the domain part.
    # TODO: Perhaps fix lago to include both short and full names?
    # Alternatively, fix all relevant code to always use only
    # full names, never short ones.
    return ModuleMapper(inventory, host_pattern.split('.')[0])
def test_he_deploy(suite_dir, ansible_host0, ansible_storage):
    answer_file_src = os.path.join(suite_dir, 'answers.conf.in')
    ansible_host0.copy(src=answer_file_src,
                       dest='/root/hosted-engine-deploy-answers-file.conf.in')

    setup_file_src = os.path.join(suite_dir, 'setup_first_he_host.sh')
    ansible_host0.copy(src=setup_file_src, dest='/root/', mode='preserve')

    he_name = backend.default_backend().engine_hostname()
    ansible_host0.shell(f'/root/setup_first_he_host.sh {he_name}')

    ansible_storage.shell('fstrim -va')
Exemplo n.º 5
0
    def _bond_nics(number, host):
        slaves = [
            HostNic(name=nic) for nic in backend.default_backend().ifaces_for(
                host.name, bonding_network_name)
        ]

        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])
Exemplo n.º 6
0
def backend():
    return _backend.default_backend()
Exemplo n.º 7
0
def storage():
    return backend.default_backend().storage_hostname()
Exemplo n.º 8
0
def hosts():
    return "~({})".format("|".join(
        backend.default_backend().hosts_hostnames()))
Exemplo n.º 9
0
def host1():
    return backend.default_backend().hosts_hostnames()[1]
Exemplo n.º 10
0
def engine():
    return backend.default_backend().engine_hostname()