[libvirt] [libvirt-test-API][PATCH 0/2] Fix some regression issues

Some issues were introduced by 137211d15 and efac4a3ec commits, fix them. jiahu (2): Give a default value on br variable in mac_to_ip Fix regression issues repos/domain/destroy.py | 4 ++-- repos/domain/install_linux_cdrom.py | 4 ++-- utils/utils.py | 7 ++----- 3 files changed, 6 insertions(+), 9 deletions(-) -- 1.8.3.1

Set 'virbr0' as defult value --- utils/utils.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/utils/utils.py b/utils/utils.py index f841c27..c3e46f6 100644 --- a/utils/utils.py +++ b/utils/utils.py @@ -349,17 +349,14 @@ def locate_utils(): result = re.search('(.*)libvirt-test-API(.*)', pwd) return result.group(0) + "/utils" -def mac_to_ip(mac,br,timeout): - """Map mac address to ip +def mac_to_ip(mac, timeout, br = 'virbr0'): + """Map mac address to ip under a specified brige Return None on FAILURE and the mac address on SUCCESS """ if not mac: return None - if not br: - return None - if timeout < 10: timeout = 10 -- 1.8.3.1

1. Using .get method to get a optional dict value 2. Adjust variables sequence during call mac_to_ip --- repos/domain/destroy.py | 4 ++-- repos/domain/install_linux_cdrom.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/repos/domain/destroy.py b/repos/domain/destroy.py index 154ffaf..36f70db 100644 --- a/repos/domain/destroy.py +++ b/repos/domain/destroy.py @@ -32,7 +32,7 @@ def destroy(params): logger = params['logger'] params.pop('logger') guestname = params['guestname'] - br = params['bridgename'] + br = params.get('bridgename','virbr0') flags = "" if params.has_key('flags'): flags = params['flags'] @@ -59,7 +59,7 @@ def destroy(params): # Get domain ip mac = utils.get_dom_mac_addr(guestname) logger.info("get ip by mac address") - ip = utils.mac_to_ip(mac,br,180) + ip = utils.mac_to_ip(mac,180,br) logger.info("the ip address of guest is %s" % ip) # Destroy domain diff --git a/repos/domain/install_linux_cdrom.py b/repos/domain/install_linux_cdrom.py index 9d3a7e9..412712b 100644 --- a/repos/domain/install_linux_cdrom.py +++ b/repos/domain/install_linux_cdrom.py @@ -147,7 +147,7 @@ def install_linux_cdrom(params): guestname = params.get('guestname') guestos = params.get('guestos') guestarch = params.get('guestarch') - br = params['bridgename'] + br = params.get('bridgename','virbr0') xmlstr = params['xml'] logger.info("the name of guest is %s" % guestname) @@ -304,7 +304,7 @@ def install_linux_cdrom(params): time.sleep(10) timeout -= 10 - ip = utils.mac_to_ip(mac,br,180) + ip = utils.mac_to_ip(mac,180,br) if not ip: logger.info(str(timeout) + "s left") -- 1.8.3.1

On 02/04/2015 06:03 PM, jiahu wrote:
1. Using .get method to get a optional dict value 2. Adjust variables sequence during call mac_to_ip --- repos/domain/destroy.py | 4 ++-- repos/domain/install_linux_cdrom.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/repos/domain/destroy.py b/repos/domain/destroy.py index 154ffaf..36f70db 100644 --- a/repos/domain/destroy.py +++ b/repos/domain/destroy.py @@ -32,7 +32,7 @@ def destroy(params): logger = params['logger'] params.pop('logger') guestname = params['guestname'] - br = params['bridgename'] + br = params.get('bridgename','virbr0') flags = "" if params.has_key('flags'): flags = params['flags'] @@ -59,7 +59,7 @@ def destroy(params): # Get domain ip mac = utils.get_dom_mac_addr(guestname) logger.info("get ip by mac address") - ip = utils.mac_to_ip(mac,br,180) + ip = utils.mac_to_ip(mac,180,br) logger.info("the ip address of guest is %s" % ip)
# Destroy domain diff --git a/repos/domain/install_linux_cdrom.py b/repos/domain/install_linux_cdrom.py index 9d3a7e9..412712b 100644 --- a/repos/domain/install_linux_cdrom.py +++ b/repos/domain/install_linux_cdrom.py @@ -147,7 +147,7 @@ def install_linux_cdrom(params): guestname = params.get('guestname') guestos = params.get('guestos') guestarch = params.get('guestarch') - br = params['bridgename'] + br = params.get('bridgename','virbr0') xmlstr = params['xml']
logger.info("the name of guest is %s" % guestname) @@ -304,7 +304,7 @@ def install_linux_cdrom(params): time.sleep(10) timeout -= 10
- ip = utils.mac_to_ip(mac,br,180) + ip = utils.mac_to_ip(mac,180,br)
if not ip: logger.info(str(timeout) + "s left") ACK and Pushed. Thanks Hongming
participants (2)
-
hongming
-
jiahu