From 7ff7e9cf5ae4d5ababa0bf7e7ccb4a8cb1064045 Mon Sep 17 00:00:00 2001 From: John Dilley Date: Thu, 7 Aug 2014 07:40:06 +0000 Subject: [PATCH] CLOUDSTACK-7268: Ignore "already exists" error in createEgressFirewallRule Signed-off-by: Santhosh Edukulla --- tools/marvin/marvin/lib/base.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py index 80596fcfcbd..f0d53a68edc 100755 --- a/tools/marvin/marvin/lib/base.py +++ b/tools/marvin/marvin/lib/base.py @@ -24,7 +24,7 @@ from marvin.cloudstackAPI import * from marvin.codes import (FAILED, FAIL, PASS, RUNNING, STOPPED, STARTING, DESTROYED, EXPUNGING, STOPPING, BACKED_UP, BACKING_UP) -from marvin.cloudstackException import GetDetailExceptionInfo +from marvin.cloudstackException import GetDetailExceptionInfo, CloudstackAPIException from marvin.lib.utils import validateList, is_server_ssh_ready, random_gen # Import System modules import time @@ -340,12 +340,17 @@ class VirtualMachine: ipaddressid=public_ip.ipaddress.id ) if allow_egress: - EgressFireWallRule.create( - apiclient=apiclient, - networkid=virtual_machine.nic[0].networkid, - protocol='All', - cidrlist='0.0.0.0/0' - ) + try: + EgressFireWallRule.create( + apiclient=apiclient, + networkid=virtual_machine.nic[0].networkid, + protocol='All', + cidrlist='0.0.0.0/0' + ) + except CloudstackAPIException, e: + # This could fail because we've already set up the same rule + if not "There is already a firewall rule specified".lower() in e.errorMsg.lower(): + raise virtual_machine.ssh_ip = nat_rule.ipaddress virtual_machine.public_ip = nat_rule.ipaddress