Fixed old name and added accidentaly deleted function
Change-Id: I7f78f12f0163173cd52ece7985006db61fdc56c3
This commit is contained in:
@@ -640,7 +640,7 @@ def generateAnswerFile(outputFile, overrides={}):
|
||||
def single_step_aio_install(options):
|
||||
""" Installs an All in One host on this host"""
|
||||
|
||||
options.install_hosts = utils.getLocalhostIP()
|
||||
options.install_hosts = utils.get_localhost_ip()
|
||||
|
||||
# Also allow the command line to set values for any of these options
|
||||
# by testing if they have been set before we set them here
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
from .datastructures import SortedDict
|
||||
from .decorators import retry
|
||||
from .network import get_localhost_ip, host2ip, force_ip
|
||||
from .network import get_localhost_ip, host2ip, force_ip, device_from_ip
|
||||
from .shell import ScriptRunner, execute
|
||||
from .strings import color_text, mask_string
|
||||
|
||||
@@ -10,5 +10,5 @@ from .strings import color_text, mask_string
|
||||
__all__ = ('SortedDict',
|
||||
'retry',
|
||||
'ScriptRunner', 'execute',
|
||||
'get_localhost_ip', 'host2ip', 'force_ip',
|
||||
'get_localhost_ip', 'host2ip', 'force_ip', 'device_from_ip',
|
||||
'color_text', 'mask_string')
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import re
|
||||
import socket
|
||||
|
||||
from .shell import execute
|
||||
from .shell import execute, ScriptRunner
|
||||
|
||||
|
||||
def get_localhost_ip():
|
||||
@@ -72,3 +72,14 @@ def force_ip(host, allow_localhost=False):
|
||||
if not ipv4_regex.match(host) or not ipv6_regex.match(host):
|
||||
host = host2ip(host, allow_localhost=allow_localhost)
|
||||
return host
|
||||
|
||||
|
||||
def device_from_ip(ip):
|
||||
server = ScriptRunner()
|
||||
server.append("DEVICE=$(ip address show to %s | head -n 1 |"
|
||||
" sed -e 's/.*: \(.*\):.*/\\1/g')" % ip)
|
||||
# Test device, raises an exception if it doesn't exist
|
||||
server.append("ip link show \"$DEVICE\" > /dev/null")
|
||||
server.append("echo $DEVICE")
|
||||
rv, stdout = server.execute()
|
||||
return stdout.strip()
|
||||
|
||||
Reference in New Issue
Block a user