Merge branch 'master' of ssh://git.planet-lab.org/git/plstackapi
diff --git a/planetstack/core/admin.py b/planetstack/core/admin.py
index 1d64d9c..6fcc3f9 100644
--- a/planetstack/core/admin.py
+++ b/planetstack/core/admin.py
@@ -535,7 +535,7 @@
 
 class DeploymentAdmin(PlanetStackBaseAdmin):
     model = Deployment
-    fieldList = ['backend_status_text', 'name', 'sites', 'images', 'flavors', 'accessControl']
+    fieldList = ['backend_status_text', 'name', 'availability_zone', 'sites', 'images', 'flavors', 'accessControl']
     fieldsets = [(None, {'fields': fieldList, 'classes':['suit-tab suit-tab-sites']})]
     inlines = [DeploymentPrivilegeInline,NodeInline,TagInline] # ,ImageDeploymentsInline]
     list_display = ['backend_status_icon', 'name']
@@ -700,6 +700,15 @@
             'service': LinkedSelect
         }
 
+    def clean(self):
+        cleaned_data = super(SliceForm, self).clean()
+        name = cleaned_data.get('name')
+        site_id = cleaned_data.get('site')
+        site = Slice.objects.get(id=site_id)
+        if not name.startswith(site.login_base):
+            raise forms.ValidationError('slice name must begin with %s' % site.login_base)
+        return cleaned_data
+
 class SliceAdmin(PlanetStackBaseAdmin):
     form = SliceForm
     fieldList = ['backend_status_text', 'site', 'name', 'serviceClass', 'enabled','description', 'service', 'slice_url', 'max_slivers']
diff --git a/planetstack/core/models/site.py b/planetstack/core/models/site.py
index 67f38aa..160b426 100644
--- a/planetstack/core/models/site.py
+++ b/planetstack/core/models/site.py
@@ -174,6 +174,7 @@
     admin_tenant = models.CharField(max_length=200, null=True, blank=True, help_text="Name of the tenant the admin user belongs to")

     auth_url = models.CharField(max_length=200, null=True, blank=True, help_text="Auth url for the deployment")
     backend_type = models.CharField(max_length=200, null=True, blank=True, help_text="Type of deployment, e.g. EC2, OpenStack, or OpenStack version")
+    availability_zone = models.CharField(max_length=200, null=True, blank=True, help_text="OpenStack availability zone")
 
     # smbaker: the default of 'allow all' is intended for evolutions of existing
     #    deployments. When new deployments are created via the GUI, they are
diff --git a/planetstack/openstack/driver.py b/planetstack/openstack/driver.py
index 4f1c177..093ab5a 100644
--- a/planetstack/openstack/driver.py
+++ b/planetstack/openstack/driver.py
@@ -417,7 +417,7 @@
 
         return (subnet_id, subnet)
 
-    def spawn_instance(self, name, key_name=None, hostname=None, image_id=None, security_group=None, pubkeys=[], nics=None, metadata=None, userdata=None, flavor_name=None):
+    def spawn_instance(self, name, key_name=None, availability_zone=None, hostname=None, image_id=None, security_group=None, pubkeys=[], nics=None, metadata=None, userdata=None, flavor_name=None):
         if not flavor_name:
             flavor_name = self.config.nova_default_flavor
 
@@ -430,9 +430,16 @@
         #if pubkeys:
         #    files["/root/.ssh/authorized_keys"] = "\n".join(pubkeys).encode('base64')
         hints = {}
-        availability_zone = None
+        
+        # determine availability zone and compute host 
+        availability_zone_filter = None
+        if not availability_zone:
+            availability_zone_filter = 'nova'
+        else: 
+            availability_zone_filter = availability_zone
         if hostname:
-            availability_zone = 'nova:%s' % hostname.split('.')[0]
+            availability_zone_filter += ':%s' % hostname.split('.')[0]
+
         server = self.shell.nova.servers.create(
                                             name=name,
                                             key_name = key_name,
@@ -441,7 +448,7 @@
                                             security_group = security_group,
                                             #files = files,
                                             scheduler_hints=hints,
-                                            availability_zone=availability_zone,
+                                            availability_zone=availability_zone_filter,
                                             nics=nics,
                                             networks=nics,
                                             meta=metadata,