Skip to main content

Translate ephemeral virtual machines names into IP addresses for python projects without requiring any modification to the libraries or any external domain name server

Project description

[![Build Status](https://travis-ci.org/internap/python-hostsresolver.svg?branch=master)](https://travis-ci.org/internap/python-hostsresolver) [![PyPI version](https://badge.fury.io/py/python-hostsresolver.svg)](http://badge.fury.io/py/python-hostsresolver)

Translate ephemeral virtual machines names into IP addresses for python projects without requiring any modification to the libraries or any external domain name server.

Background

When performing integration testing using ephemeral virtual machines, it is not always convenient to have a real domain name server to resolve the IP address of each virtual machine, especially if multiple instances of this test is to be ran simultaneously on the same host.

In most of the cases, it is possible to use directly the IP addresses of the virtual machines but in some other cases the domain name must be used. This is the case for Openstack Keystone where the catalog contains the URL of the services.

Supported setup

This project is specifically designed for python projects interacting with Openstack virtual machines managed by Vagrant. It is however possible to make it resolve any name by providing the content of a hosts file.

Usage

### Standard setup ###

The IP addresses of Vagrant managed virtual machines will be mapped to the name provided to Vagrant as if it was a hostname. vagrant ssh-config will be used internally to fetch the IP address.

>>> from hostsresolver import vagrant_source as resolver
>>> resolver.install('vagrant_project_folder/')

### Using hostmanager plugin ###

It is possible to specify the virtual machine used to download the hostsfile. If not provided, the first available virtual machine will be used. In this case, we will use /etc/hosts downloaded from dns.example.org.

>>> from hostsresolver import vagrant_hostmanager_source as resolver
>>> resolver.install('vagrant_project_folder/', 'dns.example.org')

### Using a custom hosts file ###

To simply override some domain name addresses, a custom hosts file may be loaded.

>>> from hostsresolver import hostsfile_source as resolver
>>> resolver.install('my_project_folder/hosts')

Licence

Licensed under the Apache License, Version 2.0

Contributing

Feel free to raise issues and send some pull request, we’ll be happy to look at them!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-hostsresolver-0.0.1.tar.gz (12.2 kB view details)

Uploaded Source

Built Distributions

python_hostsresolver-0.0.1-py2.py3-none-any.whl (8.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file python-hostsresolver-0.0.1.tar.gz.

File metadata

File hashes

Hashes for python-hostsresolver-0.0.1.tar.gz
Algorithm Hash digest
SHA256 d85e8cc9504ea2b6aa0ff6f54d322514ad8c97f37aa46b0211a75688082e0e34
MD5 784b8c719f3fe17dc22afe4bbe2d4257
BLAKE2b-256 8d98a315d66e4b18b6cb160dec9948fcb4bfbd1ddb583a9fe56344476fe8ea67

See more details on using hashes here.

File details

Details for the file python_hostsresolver-0.0.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for python_hostsresolver-0.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7b5026e2aafcc7f6285c2d15612075f6855292369066b0d410fcb39170bae629
MD5 0f5861a48bcee7b337c07bd02a1a5111
BLAKE2b-256 8c8509089b4362069e34fe839f7250311cfd7e2675607475cc1ab1d97d39bdde

See more details on using hashes here.

File details

Details for the file python-hostsresolver-0.0.1.linux-x86_64.tar.gz.

File metadata

File hashes

Hashes for python-hostsresolver-0.0.1.linux-x86_64.tar.gz
Algorithm Hash digest
SHA256 7979de6699887ed334f80c71b3c435662536e2eb8aa08a3c9bdb0dd8498a838f
MD5 2e193fdaa65508f6f651b1abf48189bb
BLAKE2b-256 4c2f7c5bfd2b45039c855746a1eeaf6933069e793de499fdf868066c558f4aa1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page