Package ganeti :: Package utils :: Module nodesetup
[hide private]
[frames] | no frames]

Module nodesetup

source code

Utility functions for manipulating /etc/hosts.

Functions [hide private]
 
SetEtcHostsEntry(file_name, ip, hostname, aliases)
Sets the name of an IP address and hostname in /etc/hosts.
source code
 
AddHostToEtcHosts(hostname, ip)
Wrapper around SetEtcHostsEntry.
source code
 
RemoveEtcHostsEntry(file_name, hostname)
Removes a hostname from /etc/hosts.
source code
 
RemoveHostFromEtcHosts(hostname)
Wrapper around RemoveEtcHostsEntry.
source code

Imports: StringIO, constants, algo, io


Function Details [hide private]

SetEtcHostsEntry(file_name, ip, hostname, aliases)

source code 

Sets the name of an IP address and hostname in /etc/hosts.

Parameters:
  • file_name (str) - path to the file to modify (usually /etc/hosts)
  • ip (str) - the IP address
  • hostname (str) - the hostname to be added
  • aliases (list) - the list of aliases to add for the hostname

AddHostToEtcHosts(hostname, ip)

source code 

Wrapper around SetEtcHostsEntry.

Parameters:
  • hostname (str) - a hostname that will be resolved and added to constants.ETC_HOSTS
  • ip (str) - The ip address of the host

RemoveEtcHostsEntry(file_name, hostname)

source code 

Removes a hostname from /etc/hosts.

IP addresses without names are removed from the file.

Parameters:
  • file_name (str) - path to the file to modify (usually /etc/hosts)
  • hostname (str) - the hostname to be removed

RemoveHostFromEtcHosts(hostname)

source code 

Wrapper around RemoveEtcHostsEntry.

Parameters:
  • hostname (str) - hostname that will be resolved and its full and shot name will be removed from constants.ETC_HOSTS