update Slice admin
diff --git a/plstackapi/core/api/slices.py b/plstackapi/core/api/slices.py
index 1072c07..a0cc8f8 100644
--- a/plstackapi/core/api/slices.py
+++ b/plstackapi/core/api/slices.py
@@ -6,20 +6,6 @@
 from plstackapi.core.models import Slice
 from plstackapi.core.api.sites import _get_sites
 
-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 _get_slices(filter):
     if isinstance(filter, StringTypes) and filter.isdigit():
         filter = int(filter)
@@ -36,7 +22,6 @@
  
 def add_slice(auth, fields):
     driver = OpenStackDriver(client = auth_check(auth))
-    validate_name(fields.get('name'))
     login_base = fields['name'][:fields['name'].find('_')]
     sites = _get_sites(login_base) 
     if sites: fields['site'] = sites[0]     
@@ -88,6 +73,8 @@
     driver = OpenStackDriver(client = auth_check(auth))   
     slices = _get_slices(id)
     for slice in slices:
+        driver.delete_network(slice.network_id)
+        driver.delete_router(slice.router_id)
         driver.delete_slice(id=slice.tenant_id) 
         slice.delete()
     return 1
diff --git a/plstackapi/core/models/slice.py b/plstackapi/core/models/slice.py
index a18a09e..b080924 100644
--- a/plstackapi/core/models/slice.py
+++ b/plstackapi/core/models/slice.py
@@ -10,7 +10,7 @@
 # Create your models here.
 
 class Slice(PlCoreBase):
-    tenant_id = models.CharField(max_length=200, help_text="Keystone tenant id")
+    tenant_id = models.CharField(max_length=200, help_text="Keystone tenant id", blank=True)
     name = models.CharField(unique=True, help_text="The Name of the Slice", max_length=80)
     enabled = models.BooleanField(default=True, help_text="Status for this Slice")
     SLICE_CHOICES = (('plc', 'PLC'), ('delegated', 'Delegated'), ('controller','Controller'), ('none','None'))
@@ -24,6 +24,35 @@
 
     def __unicode__(self):  return u'%s' % (self.name)
 
+    def save(self, *args, **kwds):
+
+        driver = OpenStackDriver()
+        if not self.tenant_id:
+            nova_fields = {'tenant_name': self.name,
+                   'description': self.description,
+                   'enabled': self.enabled}
+            tenant = driver.create_tenant(**nova_fields)
+            self.tenant_id = tenant.id
+
+            # create network
+            network = driver.create_network(self.name)
+            self.network_id = network['id']
+
+            # create router
+            router = driver.create_router(self.name)
+            self.router_id = router['id']
+
+        super(Slice, self).save(*args, **kwds)
+
+    def delete(self, *args, **kwds):
+        driver = OpenStackDriver()
+        if self.tenant_id:
+            driver.delete_router(self.router_id)
+            driver.delete_network(self.network_id)
+            driver.delete_tenant(self.tenant_id)
+
+        super(Slice, self).delete(*args, **kwds)    
+
 class SliceMembership(PlCoreBase):
     user = models.ForeignKey('User', related_name='slice_memberships')
     slice = models.ForeignKey('Slice', related_name='slice_memberships')
diff --git a/plstackapi/openstack/driver.py b/plstackapi/openstack/driver.py
index c7be4ad..a804db7 100644
--- a/plstackapi/openstack/driver.py
+++ b/plstackapi/openstack/driver.py
@@ -84,7 +84,7 @@
         if routers:
             router = routers[0]
         else:
-            router = self.shell.quantum.create_router({'router': {'name': name}})
+            router = self.shell.quantum.create_router({'router': {'name': name}})['router']
         if set_gateway:
             nets = self.shell.quantum.list_networks()['networks']
             for net in nets:
@@ -94,8 +94,8 @@
         
         return router
 
-    def delete_router(self, name):
-        routers = self.shell.quantum.list_routers(name=name)['routers']
+    def delete_router(self, id):
+        routers = self.shell.quantum.list_routers(id=id)['routers']
         for router in routers:
             self.shell.quantum.delete_router(router['id'])
 
@@ -116,17 +116,17 @@
         if nets: 
             net = nets[0]
         else:
-            net = self.shell.quantum.create_network({'network': {'name': name}})
+            net = self.shell.quantum.create_network({'network': {'name': name}})['network']
         return net
  
-    def delete_network(self, name):
-        nets = self.shell.quantum.list_networks(name=name)['networks']
+    def delete_network(self, id):
+        nets = self.shell.quantum.list_networks()['networks']
         for net in nets:
-            # delete all subnets:
-            #subnets = self.api.client_shell.quantum.list_subnets(network_id=net['network_id'])['subnets']
-            for subnet_id in net['subnets']:
-                self.delete_subnet(subnet_id)
-            self.shell.quantum.delete_network(net['id'])
+            if net['id'] == id:
+                # delete all subnets:
+                for subnet_id in net['subnets']:
+                    self.delete_subnet(subnet_id)
+                self.shell.quantum.delete_network(net['id'])
         return 1
     
     def create_subnet(self, name, network_id, cidr_ip, ip_version, start, end):
@@ -178,7 +178,6 @@
 
     def delete_keypair(self, id):
         keys = self.shell.nova.keypairs.findall(id=id)
-        print keys
         for key in keys:
             self.shell.nova.keypairs.delete(key) 
         return 1