Merge pick up, tweaked role/site/plcore_base or os_manager path when OpenStack not...
[plstackapi.git] / planetstack / openstack / manager.py
similarity index 92%
rename from plstackapi/openstack/manager.py
rename to planetstack/openstack/manager.py
index 669a05f..166ad19 100644 (file)
@@ -1,17 +1,17 @@
 from netaddr import IPAddress, IPNetwork
-from plstackapi.planetstack import settings
+from planetstack import settings
 from django.core import management
-management.setup_environ(settings)
-from plstackapi.planetstack.config import Config
+from planetstack.config import Config
 try:
-    from plstackapi.openstack.client import OpenStackClient
-    from plstackapi.openstack.driver import OpenStackDriver
-    from plstackapi.core.models import * 
+    from openstack.client import OpenStackClient
+    from openstack.driver import OpenStackDriver
+    from core.models import * 
     has_openstack = True
 except:
     has_openstack = False
 
-manager_enabled = Config().api_nova_enabled
+#manager_enabled = Config().api_nova_enabled
+manager_enabled = False
 
 def require_enabled(callable):
     def wrapper(*args, **kwds):
@@ -57,7 +57,7 @@ class OpenStackManager:
         self.client = OpenStackClient()
         self.driver = OpenStackDriver(client=self.client)
         self.caller = self.driver.admin_user
-        self.caller.user_id = self.caller.id 
+        self.caller.kuser_id = self.caller.id 
 
     @require_enabled
     def save_role(self, role):
@@ -85,26 +85,26 @@ class OpenStackManager:
 
     @require_enabled
     def save_user(self, user):
-        if not user.user_id:
+        if not user.kuser_id:
             name = user.email[:user.email.find('@')]
             user_fields = {'name': name,
                            'email': user.email,
                            'password': user.password,
                            'enabled': True}
             keystone_user = self.driver.create_user(**user_fields)
-            user.user_id = keystone_user.id
+            user.kuser_id = keystone_user.id
         if user.site:
-            self.driver.add_user_role(user.user_id, user.site.tenant_id, 'user')
+            self.driver.add_user_role(user.kuser_id, user.site.tenant_id, 'user')
             if user.is_admin:
-                self.driver.add_user_role(user.user_id, user.site.tenant_id, 'admin')
+                self.driver.add_user_role(user.kuser_id, user.site.tenant_id, 'admin')
             else:
                 # may have admin role so attempt to remove it
-                self.driver.delete_user_role(user.user_id, user.site.tenant_id, 'admin')
+                self.driver.delete_user_role(user.kuser_id, user.site.tenant_id, 'admin')
   
     @require_enabled
     def delete_user(self, user):
-        if user.user_id:
-            self.driver.delete_user(user.user_id)        
+        if user.kuser_id:
+            self.driver.delete_user(user.kuser_id)        
     
     @require_enabled
     def save_site(self, site, add_role=True):
@@ -114,7 +114,7 @@ class OpenStackManager:
                                                enabled=site.enabled)
             site.tenant_id = tenant.id
             # give caller an admin role at the tenant they've created
-            self.driver.add_user_role(self.caller.user_id, tenant.id, 'admin')
+            self.driver.add_user_role(self.caller.kuser_id, tenant.id, 'admin')
 
         # update the record
         if site.id and site.tenant_id:
@@ -137,7 +137,7 @@ class OpenStackManager:
             slice.tenant_id = tenant.id
 
             # give caller an admin role at the tenant they've created
-            self.driver.add_user_role(self.caller.user_id, tenant.id, 'admin')
+            self.driver.add_user_role(self.caller.kuser_id, tenant.id, 'admin')
 
             # refresh credentials using this tenant
             self.driver.shell.connect(username=self.driver.shell.keystone.username,