Check whether the security group id is integer

Fixed Bug 1206847.

Change-Id: I2194d6538a5c5475b876ee026b5d625be2df076f
This commit is contained in:
Vincent Hou 2013-07-31 05:47:53 -04:00
parent 4ab2b60850
commit 852e2e5f31
2 changed files with 10 additions and 2 deletions

View File

@ -353,3 +353,12 @@ def _load_entry_point(ep_name, name=None):
return ep.load()
except (ImportError, pkg_resources.UnknownExtra, AttributeError):
continue
def is_integer_like(val):
"""Returns validation of a value as an integer."""
try:
value = int(val)
return True
except (TypeError, ValueError, AttributeError):
return False

View File

@ -30,7 +30,6 @@ import time
from novaclient import exceptions
from novaclient.openstack.common import strutils
from novaclient.openstack.common import timeutils
from novaclient.openstack.common import uuidutils
from novaclient import utils
from novaclient.v1_1 import availability_zones
from novaclient.v1_1 import quotas
@ -1918,7 +1917,7 @@ def _print_secgroups(secgroups):
def _get_secgroup(cs, secgroup):
# Check secgroup is an ID
if uuidutils.is_uuid_like(strutils.safe_encode(secgroup)):
if utils.is_integer_like(strutils.safe_encode(secgroup)):
try:
return cs.security_groups.get(secgroup)
except exceptions.NotFound: