merge latest code
diff --git a/plstackapi/core/api/deployment_networks.py b/plstackapi/core/api/deployment_networks.py
index 812ca15..80b4ff3 100644
--- a/plstackapi/core/api/deployment_networks.py
+++ b/plstackapi/core/api/deployment_networks.py
@@ -2,7 +2,17 @@
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, int):
+ deployment_networks = DeploymentNetwork.objects.filter(id=filter)
+ elif isinstance(filter, StringTypes):
+ deployment_networks = DeploymentNetwork.objects.filter(name=filter)
+ elif isinstance(filer, dict):
+ deployment_networks = DeploymentNetwork.objects.filter(**filter)
+ else:
+ deployment_networks = []
+ return deployment_networks
def add_deployment_network(auth, name):
auth_check(auth)
@@ -12,14 +22,14 @@
def delete_deployment_network(auth, filter={}):
auth_check(auth)
- deployments = DeploymentNetwork.objects.filter(**filter)
+ deployments = _get_deployment_networks(filter)
for deployment in deployments:
deployment.delete()
return 1
def get_deployment_networks(auth, filter={}):
auth_check(auth)
- deployments = DeploymentNetwork.objects.filter(**filter)
+ deployments = _get_deployment_networks(filter)
return deployments
diff --git a/plstackapi/core/api/flavors.py b/plstackapi/core/api/flavors.py
index a2d0b23..ee55f73 100644
--- a/plstackapi/core/api/flavors.py
+++ b/plstackapi/core/api/flavors.py
@@ -3,6 +3,16 @@
from plstackapi.core.api.auth import auth_check
from plstackapi.core.models import Flavor
+def _get_flavors(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):
+ flavors = Flavor.objects.filter(**filter)
+ else:
+ flavors = []
+ return flavors
def add_flavor(auth, fields={}):
"""not implemented"""
@@ -14,7 +24,7 @@
def get_flavors(auth, filter={}):
auth_check(auth)
- flavors = Flavor.objects.filter(**filter)
+ flavors = _get_flavors(filter)
return flavors
diff --git a/plstackapi/core/api/images.py b/plstackapi/core/api/images.py
index b773b0b..0b14043 100644
--- a/plstackapi/core/api/images.py
+++ b/plstackapi/core/api/images.py
@@ -3,6 +3,16 @@
from plstackapi.core.api.auth import auth_check
from plstackapi.core.models import Image
+def _get_images(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):
+ images = image.objects.filter(**filter)
+ else:
+ images = []
+ return images
def add_image(auth, fields={}):
"""not implemented"""
@@ -14,7 +24,7 @@
def get_images(auth, filter={}):
auth_check(auth)
- images = Image.objects.filter(**filter)
+ images = _get_images(filter)
return images
diff --git a/plstackapi/core/api/keys.py b/plstackapi/core/api/keys.py
index b255e98..2c90140 100644
--- a/plstackapi/core/api/keys.py
+++ b/plstackapi/core/api/keys.py
@@ -2,24 +2,24 @@
from plstackapi.openstack.driver import OpenStackDriver
from plstackapi.core.api.auth import auth_check
from plstackapi.core.models import Key, User
-
-def lookup_user(fields):
- user = None
- if 'user' in fields:
- if isinstance(fields['user'], int):
- users = User.objects.filter(id=fields['user'])
- else:
- users = User.objects.filter(email=fields['user'])
- if users:
- user = users[0]
- if not user:
- raise Exception, "No such user: %s" % fields['user']
- return user
+from plstackapi.core.api.users import _get_users
+
+
+def _get_keys(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):
+ keys = Key.objects.filter(**filter)
+ else:
+ keys = []
+ return keys
def add_key(auth, fields):
driver = OpenStackDriver(client = auth_check(auth))
- user = lookup_user(fields)
- if user: fields['user'] = user
+ users = _get_users(fields.get('user'))
+ if users: fields['user'] = users[0]
key = Key(**fields)
nova_fields = {'name': key.name,
'key': key.key}
@@ -32,7 +32,7 @@
def delete_key(auth, filter={}):
driver = OpenStackDriver(client = auth_check(auth))
- keys = Key.objects.filter(**filter)
+ keys = _get_keys(filter)
for key in keys:
driver.delete_keypair(name=key.name)
key.delete()
@@ -40,7 +40,7 @@
def get_keys(auth, filter={}):
client = auth_check(auth)
- keys = Key.objects.filter(**filter)
+ keys = _get_keys(filter)
return keys
diff --git a/plstackapi/core/api/nodes.py b/plstackapi/core/api/nodes.py
new file mode 100644
index 0000000..47934ba
--- /dev/null
+++ b/plstackapi/core/api/nodes.py
@@ -0,0 +1,34 @@
+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, int):
+ nodes = Node.objects.filter(id=filter)
+ elif isinstance(filter, StringTypes):
+ nodes = Node.objects.filter(name=filter)
+ elif isinstance(filer, dict):
+ nodes = Node.objects.filter(**filter)
+ else:
+ nodes = []
+ return nodes
+
+def add_node(auth, fields={}):
+ """not implemented"""
+ return
+
+def delete_node(auth, filter={}):
+ """not implemented"""
+ return 1
+
+def update_node(auth, id, fields={}):
+ return
+
+def get_nodes(auth, filter={}):
+ auth_check(auth)
+ nodes = _get_nodes(filter)
+ return nodes
+
+
+
diff --git a/plstackapi/core/api/roles.py b/plstackapi/core/api/roles.py
index 844fb4f..6c61e25 100644
--- a/plstackapi/core/api/roles.py
+++ b/plstackapi/core/api/roles.py
@@ -1,9 +1,21 @@
+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 Role
+def _get_roles(filter):
+ if isinstance(filter, int):
+ roles = Role.objects.filter(id=filter)
+ elif isinstance(filter, StringTypes):
+ roles = Role.objects.filter(role_type=filter)
+ elif isinstance(filter, dict):
+ roles = Role.objects.filter(**filter)
+ else:
+ roles = []
+ return roles
+
def add_role(auth, name):
driver = OpenStackDriver(client = auth_check(auth))
keystone_role = driver.create_role(name=name)
@@ -13,7 +25,7 @@
def delete_role(auth, filter={}):
driver = OpenStackDriver(client = auth_check(auth))
- roles = Role.objects.filter(**filter)
+ roles = _get_roles(filter)
for role in roles:
driver.delete_role({'id': role.role_id})
role.delete()
@@ -21,8 +33,5 @@
def get_roles(auth, filter={}):
client = auth_check(auth)
- roles = Role.objects.filter(**filter)
- return roles
+ return _get_roles(filter)
-
-
diff --git a/plstackapi/core/api/site_privileges.py b/plstackapi/core/api/site_privileges.py
new file mode 100644
index 0000000..4c4158e
--- /dev/null
+++ b/plstackapi/core/api/site_privileges.py
@@ -0,0 +1,69 @@
+import re
+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 SitePrivilege, Site, Role, User
+from plstackapi.core.api.users import _get_users
+from plstackapi.core.api.sites import _get_sites
+from plstackapi.core.api.roles import _get_roles
+
+
+def _get_site_privileges(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):
+ site_privileges = SitePrivilege.objects.filter(**filter)
+ else:
+ site_privileges = []
+ return site_privileges
+
+def add_site_privilege(auth, fields):
+ driver = OpenStackDriver(client = auth_check(auth))
+ users = _get_user(fields.get('user'))
+ sites = _get_slice(fields.get('site'))
+ roles = _get_role(fields.get('role'))
+
+ if users: fields['user'] = users[0]
+ if slices: fields['site'] = sites[0]
+ if roles: fields['role'] = roles[0]
+
+ site_privilege = SitePrivilege(**fields)
+
+ # update nova role
+ driver.add_user_role(site_privilege.user.user_id,
+ site_privilege.site.tenant_id,
+ site_privilege.role.name)
+
+ site_privilege.save()
+ return site_privilege
+
+def update_site_privilege(auth, id, **fields):
+ return
+
+def delete_site_privilege(auth, filter={}):
+ driver = OpenStackDriver(client = auth_check(auth))
+ site_privileges = _get_site_privileges(filter)
+ for site_privilege in site_privileges:
+ driver.delete_user_role(user_id=site_privilege.user.id,
+ tenant_id = site_privilege.site.tenant_id,
+ role_name = site_privilege.role.name)
+ site_privilege.delete()
+ return 1
+
+def get_site_privileges(auth, filter={}):
+ client = auth_check(auth)
+ users = _get_users(filter.get('user'))
+ sites = _get_slices(filter.get('site'))
+ roles = _get_roles(filter.get('role'))
+
+ if users: filter['user'] = users[0]
+ if sites: filter['site'] = sites[0]
+ if roles: filter['role'] = roles[0]
+
+ site_privileges = _get_site_privileges(filter)
+ return site_privileges
+
+
+
diff --git a/plstackapi/core/api/sites.py b/plstackapi/core/api/sites.py
index 0d07605..540f815 100644
--- a/plstackapi/core/api/sites.py
+++ b/plstackapi/core/api/sites.py
@@ -2,7 +2,18 @@
from plstackapi.openstack.driver import OpenStackDriver
from plstackapi.core.api.auth import auth_check
from plstackapi.core.models import Site
-
+
+
+def _get_sites(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):
+ sites = Site.objects.filter(**filter)
+ else:
+ sites = []
+ return sites
def add_site(auth, fields):
driver = OpenStackDriver(client = auth_check(auth))
@@ -17,7 +28,7 @@
def update_site(auth, id, **fields):
driver = OpenStackDriver(client = auth_check(auth))
- sites = Site.objects.filter(id=id)
+ sites = _get_sites(id)
if not sites:
return
@@ -33,7 +44,7 @@
def delete_site(auth, filter={}):
driver = OpenStackDriver(client = auth_check(auth))
- sites = Site.objects.filter(**filter)
+ sites = _get_sites(id)
for site in sites:
driver.delete_tenant(id=site.tenant_id)
site.delete()
@@ -41,7 +52,7 @@
def get_sites(auth, filter={}):
client = auth_check(auth)
- sites = Site.objects.filter(**filter)
+ sites = _get_sites(id)
return sites
diff --git a/plstackapi/core/api/slice_memberships.py b/plstackapi/core/api/slice_memberships.py
new file mode 100644
index 0000000..9193632
--- /dev/null
+++ b/plstackapi/core/api/slice_memberships.py
@@ -0,0 +1,69 @@
+import re
+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 SliceMembership, Slice, Role, User
+from plstackapi.core.api.users import _get_users
+from plstackapi.core.api.slices import _get_slices
+from plstackapi.core.api.roles import _get_roles
+
+def _get_slice_memberships(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):
+ slice_memberships = SitePrivilege.objects.filter(**filter)
+ else:
+ slice_memberships = []
+ return slice_memberships
+
+
+def add_slice_membership(auth, fields):
+ driver = OpenStackDriver(client = auth_check(auth))
+ users = _get_users(fields.get('user'))
+ slices = _get_slices(fields.get('slice'))
+ roles = _get_roles(fields.get('role'))
+
+ if users: fields['user'] = users[0]
+ if slices: fields['slice'] = slices[0]
+ if roles: fields['role'] = roles[0]
+
+ slice_membership = SliceMembership(**fields)
+
+ # update nova role
+ driver.add_user_role(slice_membership.user.user_id,
+ slice_membership.slice.tenant_id,
+ slice_membership.role.name)
+
+ slice_membership.save()
+ return slice_membership
+
+def update_slice_membership(auth, id, **fields):
+ return
+
+def delete_slice_membership(auth, filter={}):
+ driver = OpenStackDriver(client = auth_check(auth))
+ slice_memberships = _get_slice_memberships(filter)
+ for slice_membership in slice_memberships:
+ driver.delete_user_role(user_id=slice_membership.user.id,
+ tenant_id = slice_membership.slice.tenant_id,
+ role_name = slice_membership.role.name)
+ slice_membership.delete()
+ return 1
+
+def get_slice_memberships(auth, filter={}):
+ client = auth_check(auth)
+ users = _get_users(fields.get('user'))
+ slices = _get_slices(fields.get('slice'))
+ roles = _get_roles(fields.get('role'))
+
+ if users: fields['user'] = users[0]
+ if slices: fields['slice'] = slices[0]
+ if roles: fields['role'] = roles[0]
+
+ slice_memberships = _get_slice_memberships(filter)
+ return slice_memberships
+
+
+
diff --git a/plstackapi/core/api/slices.py b/plstackapi/core/api/slices.py
index 3f50050..731fa75 100644
--- a/plstackapi/core/api/slices.py
+++ b/plstackapi/core/api/slices.py
@@ -2,43 +2,26 @@
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 Slice, Site
+from plstackapi.core.models import Slice
+from plstackapi.core.api.sites import _get_sites
+
+
+def _get_slices(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):
+ slices = Slice.objects.filter(**filter)
+ else:
+ slices = []
+ return slices
+
-def validate_name(name):
- # N.B.: Responsibility of the caller to ensure that login_base
- # portion of the slice name corresponds to a valid site, if
- # desired.
-
- # 1. Lowercase.
- # 2. Begins with login_base (letters or numbers).
- # 3. Then single underscore after login_base.
- # 4. Then letters, numbers, or underscores.
- good_name = r'^[a-z0-9]+_[a-zA-Z0-9_]+$'
- if not name or \
- not re.match(good_name, name):
- raise Exception, "Invalid slice name: %s" % name
-
-def lookup_site(fields):
- site = None
- if 'name' in fields:
- validate_name(fields['name'])
- login_base = fields['name'][:fields['name'].find('_')]
- sites = Site.objects.filter(login_base=login_base)
- if sites:
- site = sites[0]
- elif 'site' in fields:
- if isinstance(fields['site'], int):
- sites = Site.objects.filter(id=fields['site'])
- else:
- sites = Site.objects.filter(login_base=fields['site'])
- if sites:
- site = sites[0]
- return site
-
def add_slice(auth, fields):
driver = OpenStackDriver(client = auth_check(auth))
- site = lookup_site(fields)
- if site: fields['site'] = site
+ sites = _get_sites(fields.get('site'))
+ if sites: fields['site'] = sites[0]
slice = Slice(**fields)
# create tenant
nova_fields = {'tenant_name': slice.name,
@@ -60,7 +43,7 @@
def update_slice(auth, id, **fields):
driver = OpenStackDriver(client = auth_check(auth))
- slices = Slice.objects.filter(id=id)
+ slices = _get_slices(id)
if not slices:
return
@@ -76,15 +59,15 @@
driver.update_tenant(slice.tenant_id, **nova_fields)
# update db record
- site = lookup_site(fields)
- if site: fields['site'] = site
+ sites = _get_sites(fields.get('site'))
+ if sites: fields['site'] = sites[0]
slice.update(**fields)
return slice
def delete_slice(auth, filter={}):
driver = OpenStackDriver(client = auth_check(auth))
- slices = Slice.objects.filter(**filter)
+ slices = _get_slices(id)
for slice in slices:
driver.delete_slice(id=slice.tenant_id)
slice.delete()
@@ -93,9 +76,9 @@
def get_slices(auth, filter={}):
client = auth_check(auth)
if 'site' in filter:
- site = lookup_site(filter)
- if site: filter['site'] = site
- slices = Slice.objects.filter(**filter)
+ sites = _get_sites(filter.get('site'))
+ if sites: filter['site'] = sites[0]
+ slices = _get_slices(filter)
return slices
diff --git a/plstackapi/core/api/slivers.py b/plstackapi/core/api/slivers.py
new file mode 100644
index 0000000..0bdaa5d
--- /dev/null
+++ b/plstackapi/core/api/slivers.py
@@ -0,0 +1,74 @@
+import re
+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 Sliver, Slice
+from plstackapi.core.api.flavors import _get_flavors
+from plstackapi.core.api.images import _get_images
+from plstackapi.core.api.keys import _get_keys
+from plstackapi.core.api.slices import _get_slices
+from plstackapi.core.api.deployment_networks import _get_deployment_networks
+from plstackapi.core.api.nodes import _get_nodes
+
+
+def _get_slivers(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):
+ slivers = Sliver.objects.filter(**filter)
+ else:
+ slivers = []
+ return slivers
+
+def add_sliver(auth, fields):
+ driver = OpenStackDriver(client = auth_check(auth))
+
+ flavors = _get_flavor(fields.get('flavor'))
+ if flavors: fields['flavor'] = flavors[0]
+ images = _get_images(fields.get('image'))
+ if images: fields['image'] = images[0]
+ keys = _get_keys(fields.get('get'))
+ if keys: fields['key'] = keys[0]
+ slices = _get_slices(fields.get('slice'))
+ if slices: fields['slice'] = slices[0]
+ deployment_networks = _get_deployment_networks(field.get('deployment_network'))
+ if deployment_networks: fields['deployment_network'] = deployment_networks[0]
+ nodes = _get_nodes(fields.get('node'))
+ if nodes: fields['node'] = nodess[0]
+
+ sliver = Sliver(**fields)
+ # create quantum sliver
+ sliver = driver.spawn_instance(name=sliver.name,
+ key_name = sliver.key.name,
+ flavor=sliver.flavor.name,
+ image = sliver.image.name,
+ hostname = sliver.node.hostname )
+
+ sliver.instance_id=sliver.id
+
+ sliver.save()
+ return sliver
+
+def update_sliver(auth, sliver, **fields):
+ return
+
+def delete_sliver(auth, filter={}):
+ driver = OpenStackDriver(client = auth_check(auth))
+ slivers = _get_slivers(filter)
+ for sliver in slivers:
+ driver.destroy_instance(sliver.sliver_id)
+ sliver.delete()
+ return 1
+
+def get_slivers(auth, filter={}):
+ client = auth_check(auth)
+ if 'slice' in filter:
+ slices = _get_slices(filter.get('slice'))
+ if slices: filter['slice'] = slices[0]
+ slivers = _get_slivers(filter)
+ return slivers
+
+
+
diff --git a/plstackapi/core/api/subnets.py b/plstackapi/core/api/subnets.py
new file mode 100644
index 0000000..ad53da0
--- /dev/null
+++ b/plstackapi/core/api/subnets.py
@@ -0,0 +1,61 @@
+import re
+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 Subnet
+from plstackapi.core.api.slices import _get_slices
+
+def _get_subnets(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):
+ subnets = Subnet.objects.filter(**filter)
+ else:
+ subnets = []
+ return subnets
+
+def add_subnet(auth, fields):
+ driver = OpenStackDriver(client = auth_check(auth))
+ slices = _get_slice(fields.get('slice'))
+ if slices: fields['slice'] = slices[0]
+ subnet = Subnet(**fields)
+ # create quantum subnet
+ subnet = driver.create_subnet(network_name=subnet.name,
+ cidr_ip = subnet.cidr,
+ ip_version=subnet.ip_version,
+ start = subnet.start,
+ end = subnet.end,
+ dns_nameservers = ['8.8.8.8', '8.8.4.4'])
+
+ subnet.subnet_id=subnet.id
+
+ # add subnet as interface to slice's router
+ driver.add_router_interface(subnet.slice.router_id, subnet.subnet_id)
+
+ subnet.save()
+ return subnet
+
+def update_subnet(auth, subnet, **fields):
+ return
+
+def delete_subnet(auth, filter={}):
+ driver = OpenStackDriver(client = auth_check(auth))
+ subnets = Subnet.objects.filter(**filter)
+ for subnet in subnets:
+ driver.delete_router_interface(subnet.slice.router_id, subnet.subnet_id)
+ driver.delete_subnet(subnet.subnet_id)
+ subnet.delete()
+ return 1
+
+def get_subnets(auth, filter={}):
+ client = auth_check(auth)
+ if 'slice' in filter:
+ slice = _get_slice(filter.get('slice'))
+ if slice: filter['slice'] = slice
+ subnets = Subnet.objects.filter(**filter)
+ return subnets
+
+
+
diff --git a/plstackapi/core/api/users.py b/plstackapi/core/api/users.py
index 18a68c7..d543782 100644
--- a/plstackapi/core/api/users.py
+++ b/plstackapi/core/api/users.py
@@ -2,31 +2,30 @@
from plstackapi.openstack.driver import OpenStackDriver
from plstackapi.core.api.auth import auth_check
from plstackapi.core.models import User, Site
-
-def lookup_site(fields):
- site = None
- if 'site' in fields:
- if isinstance(fields['site'], int):
- sites = Site.objects.filter(id=fields['site'])
- else:
- sites = Site.objects.filter(login_base=fields['site'])
- if sites:
- site = sites[0]
- if not site:
- raise Exception, "No such site: %s" % fields['site']
- return site
+from plstackapi.core.api.sites import _get_sites
+
+def _get_users(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):
+ users = User.objects.filter(**filter)
+ else:
+ users = []
+ return users
def add_user(auth, fields):
driver = OpenStackDriver(client = auth_check(auth))
- site = lookup_site(fields)
- if site: fields['site'] = site
+ sites = _get_sites(fields.get('site'))
+ if sites: fields['site'] = sites[0]
user = User(**fields)
nova_fields = {'name': user.email[:user.email.find('@')],
'email': user.email,
'password': fields.get('password'),
'enabled': user.enabled}
nova_user = driver.create_user(**nova_fields)
- #driver.add_user_role(user.id, user.site.tenant_id, 'user')
+ #driver.add_user_user(user.id, user.site.tenant_id, 'user')
user.user_id=nova_user.id
user.save()
return user
@@ -47,14 +46,14 @@
if 'enabled' in fields:
nova_fields['enabled'] = fields['enabled']
driver.update_user(user.user_id, **nova_fields)
- site = lookup_site(fields)
- if site: fields['site'] = site
+ sites = _get_sites(fields.get('site'))
+ if sites: fields['site'] = sites[0]
user.update(**fields)
return user
def delete_user(auth, filter={}):
driver = OpenStackDriver(client = auth_check(auth))
- users = User.objects.filter(**filter)
+ users = _get_users(filter)
for user in users:
driver.delete_user(id=user.user_id)
user.delete()
@@ -62,7 +61,7 @@
def get_users(auth, filter={}):
client = auth_check(auth)
- users = User.objects.filter(**filter)
+ users = _get_users(filter)
return users