fix pk lookups
diff --git a/plstackapi/core/api/deployment_networks.py b/plstackapi/core/api/deployment_networks.py
index 80b4ff3..00ee2e8 100644
--- a/plstackapi/core/api/deployment_networks.py
+++ b/plstackapi/core/api/deployment_networks.py
@@ -1,14 +1,17 @@
+from types import StringTypes
from plstackapi.openstack.client import OpenStackClient
from plstackapi.openstack.driver import OpenStackDriver
from plstackapi.core.api.auth import auth_check
from plstackapi.core.models import DeploymentNetwork
def _get_deployment_networks(filter):
+ if isinstance(filter, StringTypes) and filter.isdigit():
+ filter = int(filter)
if isinstance(filter, int):
deployment_networks = DeploymentNetwork.objects.filter(id=filter)
elif isinstance(filter, StringTypes):
deployment_networks = DeploymentNetwork.objects.filter(name=filter)
- elif isinstance(filer, dict):
+ elif isinstance(filter, dict):
deployment_networks = DeploymentNetwork.objects.filter(**filter)
else:
deployment_networks = []
diff --git a/plstackapi/core/api/flavors.py b/plstackapi/core/api/flavors.py
index ee55f73..94c38eb 100644
--- a/plstackapi/core/api/flavors.py
+++ b/plstackapi/core/api/flavors.py
@@ -1,14 +1,17 @@
+from types import StringTypes
from plstackapi.openstack.client import OpenStackClient
from plstackapi.openstack.driver import OpenStackDriver
from plstackapi.core.api.auth import auth_check
from plstackapi.core.models import Flavor
def _get_flavors(filter):
+ if isinstance(filter, StringTypes) and filter.isdigit():
+ filter = int(filter)
if isinstance(filter, int):
flavors = Flavor.objects.filter(id=filter)
elif isinstance(filter, StringTypes):
flavors = Flavor.objects.filter(name=filter)
- elif isinstance(filer, dict):
+ elif isinstance(filter, dict):
flavors = Flavor.objects.filter(**filter)
else:
flavors = []
diff --git a/plstackapi/core/api/images.py b/plstackapi/core/api/images.py
index 0b14043..ef197a6 100644
--- a/plstackapi/core/api/images.py
+++ b/plstackapi/core/api/images.py
@@ -1,14 +1,17 @@
+from types import StringTypes
from plstackapi.openstack.client import OpenStackClient
from plstackapi.openstack.driver import OpenStackDriver
from plstackapi.core.api.auth import auth_check
from plstackapi.core.models import Image
def _get_images(filter):
+ if isinstance(filter, StringTypes) and filter.isdigit():
+ filter = int(filter)
if isinstance(filter, int):
images = image.objects.filter(id=filter)
elif isinstance(filter, StringTypes):
images = image.objects.filter(name=filter)
- elif isinstance(filer, dict):
+ elif isinstance(filter, dict):
images = image.objects.filter(**filter)
else:
images = []
diff --git a/plstackapi/core/api/keys.py b/plstackapi/core/api/keys.py
index 2c90140..42ffe46 100644
--- a/plstackapi/core/api/keys.py
+++ b/plstackapi/core/api/keys.py
@@ -1,3 +1,4 @@
+from types import StringTypes
from plstackapi.openstack.client import OpenStackClient
from plstackapi.openstack.driver import OpenStackDriver
from plstackapi.core.api.auth import auth_check
@@ -6,11 +7,13 @@
def _get_keys(filter):
+ if isinstance(filter, StringTypes) and filter.isdigit():
+ filter = int(filter)
if isinstance(filter, int):
keys = Key.objects.filter(id=filter)
elif isinstance(filter, StringTypes):
keys = Key.objects.filter(name=filter)
- elif isinstance(filer, dict):
+ elif isinstance(filter, dict):
keys = Key.objects.filter(**filter)
else:
keys = []
diff --git a/plstackapi/core/api/nodes.py b/plstackapi/core/api/nodes.py
index 47934ba..9b6a65c 100644
--- a/plstackapi/core/api/nodes.py
+++ b/plstackapi/core/api/nodes.py
@@ -1,14 +1,17 @@
+from types import StringTypes
from plstackapi.openstack.client import OpenStackClient
from plstackapi.openstack.driver import OpenStackDriver
from plstackapi.core.api.auth import auth_check
from plstackapi.core.models import Node
def _get_nodes(filter):
+ if isinstance(filter, StringTypes) and filter.isdigit():
+ filter = int(filter)
if isinstance(filter, int):
nodes = Node.objects.filter(id=filter)
elif isinstance(filter, StringTypes):
nodes = Node.objects.filter(name=filter)
- elif isinstance(filer, dict):
+ elif isinstance(filter, dict):
nodes = Node.objects.filter(**filter)
else:
nodes = []
diff --git a/plstackapi/core/api/roles.py b/plstackapi/core/api/roles.py
index 6c61e25..b243d78 100644
--- a/plstackapi/core/api/roles.py
+++ b/plstackapi/core/api/roles.py
@@ -6,6 +6,8 @@
def _get_roles(filter):
+ if isinstance(filter, StringTypes) and filter.isdigit():
+ filter = int(filter)
if isinstance(filter, int):
roles = Role.objects.filter(id=filter)
elif isinstance(filter, StringTypes):
diff --git a/plstackapi/core/api/site_privileges.py b/plstackapi/core/api/site_privileges.py
index 4c4158e..73280c6 100644
--- a/plstackapi/core/api/site_privileges.py
+++ b/plstackapi/core/api/site_privileges.py
@@ -1,3 +1,4 @@
+from types import StringTypes
import re
from plstackapi.openstack.client import OpenStackClient
from plstackapi.openstack.driver import OpenStackDriver
@@ -9,11 +10,13 @@
def _get_site_privileges(filter):
+ if isinstance(filter, StringTypes) and filter.isdigit():
+ filter = int(filter)
if isinstance(filter, int):
site_privileges = SitePrivilege.objects.filter(id=filter)
elif isinstance(filter, StringTypes):
site_privileges = SitePrivilege.objects.filter(name=filter)
- elif isinstance(filer, dict):
+ elif isinstance(filter, dict):
site_privileges = SitePrivilege.objects.filter(**filter)
else:
site_privileges = []
diff --git a/plstackapi/core/api/sites.py b/plstackapi/core/api/sites.py
index 540f815..daf8fa1 100644
--- a/plstackapi/core/api/sites.py
+++ b/plstackapi/core/api/sites.py
@@ -1,3 +1,4 @@
+from types import StringTypes
from plstackapi.openstack.client import OpenStackClient
from plstackapi.openstack.driver import OpenStackDriver
from plstackapi.core.api.auth import auth_check
@@ -5,11 +6,13 @@
def _get_sites(filter):
+ if isinstance(filter, StringTypes) and filter.isdigit():
+ filter = int(filter)
if isinstance(filter, int):
sites = Site.objects.filter(id=filter)
elif isinstance(filter, StringTypes):
sites = Site.objects.filter(name=filter)
- elif isinstance(filer, dict):
+ elif isinstance(filter, dict):
sites = Site.objects.filter(**filter)
else:
sites = []
diff --git a/plstackapi/core/api/slice_memberships.py b/plstackapi/core/api/slice_memberships.py
index 9193632..54a1cba 100644
--- a/plstackapi/core/api/slice_memberships.py
+++ b/plstackapi/core/api/slice_memberships.py
@@ -1,4 +1,4 @@
-import re
+from types import StringTypes
from plstackapi.openstack.client import OpenStackClient
from plstackapi.openstack.driver import OpenStackDriver
from plstackapi.core.api.auth import auth_check
@@ -8,11 +8,13 @@
from plstackapi.core.api.roles import _get_roles
def _get_slice_memberships(filter):
+ if isinstance(filter, StringTypes) and filter.isdigit():
+ filter = int(filter)
if isinstance(filter, int):
slice_memberships = SitePrivilege.objects.filter(id=filter)
elif isinstance(filter, StringTypes):
slice_memberships = SitePrivilege.objects.filter(name=filter)
- elif isinstance(filer, dict):
+ elif isinstance(filter, dict):
slice_memberships = SitePrivilege.objects.filter(**filter)
else:
slice_memberships = []
diff --git a/plstackapi/core/api/slices.py b/plstackapi/core/api/slices.py
index 731fa75..bfbc4d9 100644
--- a/plstackapi/core/api/slices.py
+++ b/plstackapi/core/api/slices.py
@@ -1,4 +1,4 @@
-import re
+from types import StringTypes
from plstackapi.openstack.client import OpenStackClient
from plstackapi.openstack.driver import OpenStackDriver
from plstackapi.core.api.auth import auth_check
@@ -7,11 +7,13 @@
def _get_slices(filter):
+ if isinstance(filter, StringTypes) and filter.isdigit():
+ filter = int(filter)
if isinstance(filter, int):
slices = Slice.objects.filter(id=filter)
elif isinstance(filter, StringTypes):
slices = Slice.objects.filter(name=filter)
- elif isinstance(filer, dict):
+ elif isinstance(filter, dict):
slices = Slice.objects.filter(**filter)
else:
slices = []
diff --git a/plstackapi/core/api/slivers.py b/plstackapi/core/api/slivers.py
index 0bdaa5d..f3807ab 100644
--- a/plstackapi/core/api/slivers.py
+++ b/plstackapi/core/api/slivers.py
@@ -1,4 +1,4 @@
-import re
+from types import StringTypes
from plstackapi.openstack.client import OpenStackClient
from plstackapi.openstack.driver import OpenStackDriver
from plstackapi.core.api.auth import auth_check
@@ -12,11 +12,13 @@
def _get_slivers(filter):
+ if isinstance(filter, StringTypes) and filter.isdigit():
+ filter = int(filter)
if isinstance(filter, int):
slivers = Sliver.objects.filter(id=filter)
elif isinstance(filter, StringTypes):
slivers = Sliver.objects.filter(name=filter)
- elif isinstance(filer, dict):
+ elif isinstance(filter, dict):
slivers = Sliver.objects.filter(**filter)
else:
slivers = []
diff --git a/plstackapi/core/api/subnets.py b/plstackapi/core/api/subnets.py
index ad53da0..33a0269 100644
--- a/plstackapi/core/api/subnets.py
+++ b/plstackapi/core/api/subnets.py
@@ -1,4 +1,4 @@
-import re
+from types import StringTypes
from plstackapi.openstack.client import OpenStackClient
from plstackapi.openstack.driver import OpenStackDriver
from plstackapi.core.api.auth import auth_check
@@ -6,11 +6,13 @@
from plstackapi.core.api.slices import _get_slices
def _get_subnets(filter):
+ if isinstance(filter, StringTypes) and filter.isdigit():
+ filter = int(filter)
if isinstance(filter, int):
subnets = Subnet.objects.filter(id=filter)
elif isinstance(filter, StringTypes):
subnets = Subnet.objects.filter(name=filter)
- elif isinstance(filer, dict):
+ elif isinstance(filter, dict):
subnets = Subnet.objects.filter(**filter)
else:
subnets = []
diff --git a/plstackapi/core/api/users.py b/plstackapi/core/api/users.py
index d543782..b2ba681 100644
--- a/plstackapi/core/api/users.py
+++ b/plstackapi/core/api/users.py
@@ -1,3 +1,4 @@
+from types import StringTypes
from plstackapi.openstack.client import OpenStackClient
from plstackapi.openstack.driver import OpenStackDriver
from plstackapi.core.api.auth import auth_check
@@ -5,11 +6,13 @@
from plstackapi.core.api.sites import _get_sites
def _get_users(filter):
+ if isinstance(filter, StringTypes) and filter.isdigit():
+ filter = int(filter)
if isinstance(filter, int):
users = User.objects.filter(id=filter)
elif isinstance(filter, StringTypes):
users = User.objects.filter(role_type=filter)
- elif isinstance(filer, dict):
+ elif isinstance(filter, dict):
users = User.objects.filter(**filter)
else:
users = []