You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bf...@apache.org on 2013/02/26 19:51:34 UTC
[12/24] git commit: refs/heads/ui-regions - scripts: Fix
security_group.py handling of args and unknown commands
scripts: Fix security_group.py handling of args and unknown commands
Checks the args length, doesn't throw IndexError when no args
passed. Also logs to security_group.log when executed with no args or unknown
command.
Review: https://reviews.apache.org/r/9588
Reviewed-by: Rohit Yadav <bh...@apache.org>
Signed-off-by: Rohit Yadav <bh...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/03838031
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/03838031
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/03838031
Branch: refs/heads/ui-regions
Commit: 0383803188eacbf948dc84de1710522e659b1790
Parents: 4318389
Author: Radoslaw Smigielski <ra...@eu.citrix.com>
Authored: Mon Feb 25 14:55:44 2013 +0000
Committer: Rohit Yadav <bh...@apache.org>
Committed: Tue Feb 26 14:12:49 2013 +0530
----------------------------------------------------------------------
scripts/vm/network/security_group.py | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/03838031/scripts/vm/network/security_group.py
----------------------------------------------------------------------
diff --git a/scripts/vm/network/security_group.py b/scripts/vm/network/security_group.py
index dcb01a7..83d7ad1 100755
--- a/scripts/vm/network/security_group.py
+++ b/scripts/vm/network/security_group.py
@@ -38,13 +38,13 @@ def can_bridge_firewall(privnic):
execute("which iptables")
except:
print "no iptables on your host machine"
- exit(1)
+ sys.exit(1)
try:
execute("which ebtables")
except:
print "no ebtables on your host machine"
- exit(2)
+ sys.exit(2)
if not os.path.exists('/var/run/cloud'):
@@ -813,6 +813,9 @@ if __name__ == '__main__':
parser.add_option("--hostIp", dest="hostIp")
parser.add_option("--hostMacAddr", dest="hostMacAddr")
(option, args) = parser.parse_args()
+ if len(args) == 0:
+ logging.debug("No command to execute")
+ sys.exit(1)
cmd = args[0]
if cmd == "can_bridge_firewall":
can_bridge_firewall(args[1])
@@ -830,3 +833,6 @@ if __name__ == '__main__':
cleanup_rules()
elif cmd == "post_default_network_rules":
post_default_network_rules(option.vmName, option.vmID, option.vmIP, option.vmMAC, option.vif, option.brname, option.dhcpSvr, option.hostIp, option.hostMacAddr)
+ else:
+ logging.debug("Unknown command: " + cmd)
+ sys.exit(1)