flavor selector
diff --git a/xos/tosca/custom_types/xos.m4 b/xos/tosca/custom_types/xos.m4
new file mode 100644
index 0000000..35af5d3
--- /dev/null
+++ b/xos/tosca/custom_types/xos.m4
@@ -0,0 +1,285 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+# Note: Tosca derived_from isn't working the way I think it should, it's not
+#    inheriting from the parent template. Until we get that figured out, use
+#    m4 macros do our inheritance
+
+define(xos_base_props,
+            no-delete:
+                type: boolean
+                default: false
+                description: do not allow Tosca to delete this object
+            no-create:
+                type: boolean
+                default: false
+                description: do not allow Tosca to create this object)
+define(xos_base_service_caps,
+            scalable:
+                type: tosca.capabilities.Scalable
+            service:
+                type: tosca.capabilities.xos.Service)
+define(xos_base_service_props,
+            view_url:
+                type: string
+                required: false)
+
+# end m4 macros
+#
+# compile this with "m4 custom_types/xos.m4 > custom_types/xos.yaml"
+
+node_types:
+    tosca.nodes.Service:
+        derived_from: tosca.nodes.Root
+        capabilities:
+            xos_base_service_caps
+        properties:
+            xos_base_service_props
+
+    tosca.nodes.VcpeService:
+        derived_from: tosca.nodes.Root
+        capabilities:
+            xos_base_service_caps
+        properties:
+            xos_base_service_props
+            backend_network_label:
+                type: string
+                required: false
+
+    tosca.nodes.User:
+        derived_from: tosca.nodes.Root
+
+        capabilities:
+            user:
+                type: tosca.capabilities.xos.User
+
+        properties:
+            password:
+                type: string
+                required: true
+            firstname:
+                type: string
+                required: true
+            lastname:
+                type: string
+                required: true
+            phone:
+                type: string
+                required: false
+            user_url:
+                type: string
+                required: false
+            public_key:
+                type: string
+                required: false
+            is_active:
+                type: boolean
+                default: true
+            is_admin:
+                type: boolean
+                default: false
+            login_page:
+                type: string
+                required: false
+
+    tosca.nodes.NetworkTemplate:
+        derived_from: tosca.nodes.Root
+
+        capabilities:
+            network_template:
+                type: tosca.capabilities.xos.NetworkTemplate
+
+        properties:
+            visibility:
+                type: string
+                default: private
+            translation:
+                type: string
+                default: none
+            shared_network_name:
+                type: string
+                required: false
+            shared_network_id:
+                type: string
+                required: false
+            topology_kind:
+                type: string
+                default: BigSwitch
+            controller_kind:
+                type: string
+                required: false
+
+    tosca.nodes.XOSNetwork:
+        derived_from: tosca.nodes.Root
+
+        capabilities:
+            network:
+                type: tosca.capabilities.xos.Network
+
+        properties:
+            ports:
+                type: string
+                required: false
+            labels:
+                type: string
+                required: false
+            permit_all_slices:
+                type: boolean
+                default: false
+            permitted_slices:
+                type: string
+                required: false
+
+    tosca.nodes.Deployment:
+        derived_from: tosca.nodes.Root
+        capabilities:
+            deployment:
+                type: tosca.capabilities.xos.Deployment
+
+    tosca.nodes.Controller:
+        derived_from: tosca.nodes.Root
+        capabilities:
+            controller:
+                type: tosca.capabilities.xos.Controller
+        properties:
+            backend_type:
+                type: string
+                required: false
+            version:
+                type: string
+                required: false
+            auth_url:
+                type: string
+                required: false
+            admin_user:
+                type: string
+                required: false
+            admin_password:
+                type: string
+                required: false
+            admin_tenant:
+                type: string
+                required: false
+            domain:
+                type: string
+                required: false
+
+    tosca.nodes.Site:
+        derived_from: tosca.nodes.Root
+        capabilities:
+            site:
+                type: tosca.capabilities.xos.Site
+        properties:
+             display_name:
+                 type: string
+                 required: false
+                 description: name of the site
+             site_url:
+                 type: string
+                 required: false
+             enabled:
+                 type: boolean
+                 default: true
+             hosts_nodes:
+                 type: boolean
+                 default: true
+             hosts_users:
+                 type: boolean
+                 default: true
+             is_public:
+                 type: boolean
+                 default: true
+             # location, longitude, latitude
+
+    tosca.nodes.Slice:
+        derived_from: tosca.nodes.Root
+        capability:
+            slice:
+                type: tosca.capabilities.xos.Slice
+
+    tosca.relationships.MemberOfSlice:
+        derived_from: tosca.relationships.Root
+        valid_target_types: [ tosca.capabilities.xos.Slice ]
+
+    tosca.relationships.MemberOfService:
+        derived_from: tosca.relationships.Root
+        valid_target_types: [ tosca.capabilities.xos.Service ]
+
+    tosca.relationships.MemberOfSite:
+        derived_from: tosca.relationships.Root
+        valid_target_types: [ tosca.capabilities.xos.Site ]
+
+    tosca.relationships.TenantOfService:
+        derived_from: tosca.relationships.Root
+        valid_target_types: [ tosca.capabilities.xos.Service ]
+
+    tosca.relationships.ControllerDeployment:
+        derived_from: tosca.relationships.Root
+        valid_target_types: [ tosca.capabilities.xos.Deployment ]
+
+    tosca.relationships SiteDeployment:
+        derived_from: tosca.relationships.Root
+        valid_target_types: [ tosca.capabilities.xos.Deployment ]
+
+    tosca.relationships.UsesController:
+        derived_from: tosca.relationships.Root
+        valid_target_types: [ tosca.capabilities.xos.Controller ]
+
+    tosca.relationships.ConnectsToNetwork:
+        derived_from: tosca.relationships.Root
+        valid_target_types: [ tosca.capabilities.xos.Network ]
+
+    #    tosca.relationships.OwnsNetwork:
+    #        derived_from: tosca.relationships.Root
+    #        valid_target_types: [ tosca.capabilities.xos.Network ]
+
+    tosca.relationships.UsesNetworkTemplate:
+        derived_from: tosca.relationships.Root
+        valid_target_types: [ tosca.capabilities.xos.NetworkTemplate ]
+
+    tosca.relationships.AdminPrivilege:
+        derived_from: tosca.relationships.Root
+        valid_target_types: [ tosca.capabilities.xos.Slice, tosca.capabiltys.xos.Site ]
+
+    tosca.relationships.AccessPrivilege:
+        derived_from: tosca.relationships.Root
+        valid_target_types: [ tosca.capabilities.xos.Slice, tosca.capabiltys.xos.Site ]
+
+    tosca.relationships.PIPrivilege:
+        derived_from: tosca.relationships.Root
+        valid_target_types: [ tosca.capabiltys.xos.Site ]
+
+    tosca.relationships.TechPrivilege:
+        derived_from: tosca.relationships.Root
+        valid_target_types: [ tosca.capabiltys.xos.Site ]
+
+    tosca.capabilities.xos.Service:
+        derived_from: tosca.capabilities.Root
+        description: An XOS Service
+
+    tosca.capabilities.xos.Deployment:
+        derived_from: tosca.capabilities.Root
+        description: An XOS Deployment
+
+    tosca.capabilities.xos.Controller:
+        derived_from: tosca.capabilities.Root
+        description: An XOS Controller
+
+    tosca.capabilities.xos.Site:
+        derived_from: tosca.capabilities.Root
+        description: An XOS Site
+
+    tosca.capabilities.xos.Slice:
+        derived_from: tosca.capabilities.Root
+        description: An XOS Slice
+
+    tosca.capabilities.xos.NetworkTemplate:
+        derived_from: tosca.capabilities.Root
+        description: An XOS network template
+
+    tosca.capabilities.xos.Network:
+        derived_from: tosca.capabilities.Root
+        description: An XOS network
+
+    tosca.capabilities.xos.User:
+        derived_from: tosca.capabilities.Root
+        description: An XOS user
diff --git a/xos/tosca/custom_types/xos.yaml b/xos/tosca/custom_types/xos.yaml
index b102b2a..16a120f 100644
--- a/xos/tosca/custom_types/xos.yaml
+++ b/xos/tosca/custom_types/xos.yaml
@@ -1 +1,280 @@
-# this file intentionally left blank
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+# Note: Tosca derived_from isn't working the way I think it should, it's not
+#    inheriting from the parent template. Until we get that figured out, use
+#    m4 macros do our inheritance
+
+
+
+
+
+# end m4 macros
+#
+# compile this with "m4 custom_types/xos.m4 > custom_types/xos.yaml"
+
+node_types:
+    tosca.nodes.Service:
+        derived_from: tosca.nodes.Root
+        capabilities:
+            scalable:
+                type: tosca.capabilities.Scalable
+            service:
+                type: tosca.capabilities.xos.Service
+        properties:
+            view_url:
+                type: string
+                required: false
+
+    tosca.nodes.VcpeService:
+        derived_from: tosca.nodes.Root
+        capabilities:
+            scalable:
+                type: tosca.capabilities.Scalable
+            service:
+                type: tosca.capabilities.xos.Service
+        properties:
+            view_url:
+                type: string
+                required: false
+            backend_network_label:
+                type: string
+                required: false
+
+    tosca.nodes.User:
+        derived_from: tosca.nodes.Root
+
+        capabilities:
+            user:
+                type: tosca.capabilities.xos.User
+
+        properties:
+            password:
+                type: string
+                required: true
+            firstname:
+                type: string
+                required: true
+            lastname:
+                type: string
+                required: true
+            phone:
+                type: string
+                required: false
+            user_url:
+                type: string
+                required: false
+            public_key:
+                type: string
+                required: false
+            is_active:
+                type: boolean
+                default: true
+            is_admin:
+                type: boolean
+                default: false
+            login_page:
+                type: string
+                required: false
+
+    tosca.nodes.NetworkTemplate:
+        derived_from: tosca.nodes.Root
+
+        capabilities:
+            network_template:
+                type: tosca.capabilities.xos.NetworkTemplate
+
+        properties:
+            visibility:
+                type: string
+                default: private
+            translation:
+                type: string
+                default: none
+            shared_network_name:
+                type: string
+                required: false
+            shared_network_id:
+                type: string
+                required: false
+            topology_kind:
+                type: string
+                default: BigSwitch
+            controller_kind:
+                type: string
+                required: false
+
+    tosca.nodes.XOSNetwork:
+        derived_from: tosca.nodes.Root
+
+        capabilities:
+            network:
+                type: tosca.capabilities.xos.Network
+
+        properties:
+            ports:
+                type: string
+                required: false
+            labels:
+                type: string
+                required: false
+            permit_all_slices:
+                type: boolean
+                default: false
+            permitted_slices:
+                type: string
+                required: false
+
+    tosca.nodes.Deployment:
+        derived_from: tosca.nodes.Root
+        capabilities:
+            deployment:
+                type: tosca.capabilities.xos.Deployment
+
+    tosca.nodes.Controller:
+        derived_from: tosca.nodes.Root
+        capabilities:
+            controller:
+                type: tosca.capabilities.xos.Controller
+        properties:
+            backend_type:
+                type: string
+                required: false
+            version:
+                type: string
+                required: false
+            auth_url:
+                type: string
+                required: false
+            admin_user:
+                type: string
+                required: false
+            admin_password:
+                type: string
+                required: false
+            admin_tenant:
+                type: string
+                required: false
+            domain:
+                type: string
+                required: false
+
+    tosca.nodes.Site:
+        derived_from: tosca.nodes.Root
+        capabilities:
+            site:
+                type: tosca.capabilities.xos.Site
+        properties:
+             display_name:
+                 type: string
+                 required: false
+                 description: name of the site
+             site_url:
+                 type: string
+                 required: false
+             enabled:
+                 type: boolean
+                 default: true
+             hosts_nodes:
+                 type: boolean
+                 default: true
+             hosts_users:
+                 type: boolean
+                 default: true
+             is_public:
+                 type: boolean
+                 default: true
+             # location, longitude, latitude
+
+    tosca.nodes.Slice:
+        derived_from: tosca.nodes.Root
+        capability:
+            slice:
+                type: tosca.capabilities.xos.Slice
+
+    tosca.relationships.MemberOfSlice:
+        derived_from: tosca.relationships.Root
+        valid_target_types: [ tosca.capabilities.xos.Slice ]
+
+    tosca.relationships.MemberOfService:
+        derived_from: tosca.relationships.Root
+        valid_target_types: [ tosca.capabilities.xos.Service ]
+
+    tosca.relationships.MemberOfSite:
+        derived_from: tosca.relationships.Root
+        valid_target_types: [ tosca.capabilities.xos.Site ]
+
+    tosca.relationships.TenantOfService:
+        derived_from: tosca.relationships.Root
+        valid_target_types: [ tosca.capabilities.xos.Service ]
+
+    tosca.relationships.ControllerDeployment:
+        derived_from: tosca.relationships.Root
+        valid_target_types: [ tosca.capabilities.xos.Deployment ]
+
+    tosca.relationships SiteDeployment:
+        derived_from: tosca.relationships.Root
+        valid_target_types: [ tosca.capabilities.xos.Deployment ]
+
+    tosca.relationships.UsesController:
+        derived_from: tosca.relationships.Root
+        valid_target_types: [ tosca.capabilities.xos.Controller ]
+
+    tosca.relationships.ConnectsToNetwork:
+        derived_from: tosca.relationships.Root
+        valid_target_types: [ tosca.capabilities.xos.Network ]
+
+    #    tosca.relationships.OwnsNetwork:
+    #        derived_from: tosca.relationships.Root
+    #        valid_target_types: [ tosca.capabilities.xos.Network ]
+
+    tosca.relationships.UsesNetworkTemplate:
+        derived_from: tosca.relationships.Root
+        valid_target_types: [ tosca.capabilities.xos.NetworkTemplate ]
+
+    tosca.relationships.AdminPrivilege:
+        derived_from: tosca.relationships.Root
+        valid_target_types: [ tosca.capabilities.xos.Slice, tosca.capabiltys.xos.Site ]
+
+    tosca.relationships.AccessPrivilege:
+        derived_from: tosca.relationships.Root
+        valid_target_types: [ tosca.capabilities.xos.Slice, tosca.capabiltys.xos.Site ]
+
+    tosca.relationships.PIPrivilege:
+        derived_from: tosca.relationships.Root
+        valid_target_types: [ tosca.capabiltys.xos.Site ]
+
+    tosca.relationships.TechPrivilege:
+        derived_from: tosca.relationships.Root
+        valid_target_types: [ tosca.capabiltys.xos.Site ]
+
+    tosca.capabilities.xos.Service:
+        derived_from: tosca.capabilities.Root
+        description: An XOS Service
+
+    tosca.capabilities.xos.Deployment:
+        derived_from: tosca.capabilities.Root
+        description: An XOS Deployment
+
+    tosca.capabilities.xos.Controller:
+        derived_from: tosca.capabilities.Root
+        description: An XOS Controller
+
+    tosca.capabilities.xos.Site:
+        derived_from: tosca.capabilities.Root
+        description: An XOS Site
+
+    tosca.capabilities.xos.Slice:
+        derived_from: tosca.capabilities.Root
+        description: An XOS Slice
+
+    tosca.capabilities.xos.NetworkTemplate:
+        derived_from: tosca.capabilities.Root
+        description: An XOS network template
+
+    tosca.capabilities.xos.Network:
+        derived_from: tosca.capabilities.Root
+        description: An XOS network
+
+    tosca.capabilities.xos.User:
+        derived_from: tosca.capabilities.Root
+        description: An XOS user
diff --git a/xos/tosca/definitions/xos.yaml b/xos/tosca/definitions/xos.yaml
deleted file mode 100644
index 2651739..0000000
--- a/xos/tosca/definitions/xos.yaml
+++ /dev/null
@@ -1,276 +0,0 @@
-# XXX for some reason, we can't use 'derived_from' to derive from a type that's
-# defined in an import. I think this is probably a bug in the Tosca
-# implementation. For now, we'll just concatenate the 1.0 definition yaml with
-# this file and use that for the definition.
-#
-# When the bug is fixed, go back to making this an import.
-
-#tosca_definitions_version: tosca_simple_yaml_1_0
-
-#node_types:
-
-tosca.nodes.XOS:
-    derived_from: tosca.nodes.Root
-    properties:
-        no-delete:
-            type: boolean
-            default: false
-            description: do not allow Tosca to delete this object
-        no-create:
-            type: boolean
-            default: false
-            description: do not allow Tosca to create this object
-
-tosca.nodes.Service:
-    derived_from: tosca.nodes.Root
-    capabilities:
-        scalable:
-            type: tosca.capabilities.Scalable
-        service:
-            type: tosca.capabilities.xos.Service
-    properties:
-        view_url:
-            type: string
-            required: false
-
-tosca.nodes.VcpeService:
-    derived_from: tosca.nodes.Service
-
-tosca.nodes.User:
-    derived_from: tosca.nodes.Root
-
-    capabilities:
-        user:
-            type: tosca.capabilities.xos.User
-
-    properties:
-        password:
-            type: string
-            required: true
-        firstname:
-            type: string
-            required: true
-        lastname:
-            type: string
-            required: true
-        phone:
-            type: string
-            required: false
-        user_url:
-            type: string
-            required: false
-        public_key:
-            type: string
-            required: false
-        is_active:
-            type: boolean
-            default: true
-        is_admin:
-            type: boolean
-            default: false
-        login_page:
-            type: string
-            required: false
-
-tosca.nodes.NetworkTemplate:
-    derived_from: tosca.nodes.Root
-
-    capabilities:
-        network_template:
-            type: tosca.capabilities.xos.NetworkTemplate
-
-    properties:
-        visibility:
-            type: string
-            default: private
-        translation:
-            type: string
-            default: none
-        shared_network_name:
-            type: string
-            required: false
-        shared_network_id:
-            type: string
-            required: false
-        topology_kind:
-            type: string
-            default: BigSwitch
-        controller_kind:
-            type: string
-            required: false
-
-tosca.nodes.XOSNetwork:
-    derived_from: tosca.nodes.Root
-
-    capabilities:
-        network:
-            type: tosca.capabilities.xos.Network
-
-    properties:
-        ports:
-            type: string
-            required: false
-        labels:
-            type: string
-            required: false
-        permit_all_slices:
-            type: boolean
-            default: false
-        permitted_slices:
-            type: string
-            required: false
-
-tosca.nodes.Deployment:
-    derived_from: tosca.nodes.Root
-    capabilities:
-        deployment:
-            type: tosca.capabilities.xos.Deployment
-
-tosca.nodes.Controller:
-    derived_from: tosca.nodes.Root
-    capabilities:
-        controller:
-            type: tosca.capabilities.xos.Controller
-    properties:
-        backend_type:
-            type: string
-            required: false
-        version:
-            type: string
-            required: false
-        auth_url:
-            type: string
-            required: false
-        admin_user:
-            type: string
-            required: false
-        admin_password:
-            type: string
-            required: false
-        admin_tenant:
-            type: string
-            required: false
-        domain:
-            type: string
-            required: false
-
-tosca.nodes.Site:
-    derived_from: tosca.nodes.Root
-    capabilities:
-        site:
-            type: tosca.capabilities.xos.Site
-    properties:
-         display_name:
-             type: string
-             required: false
-             description: name of the site
-         site_url:
-             type: string
-             required: false
-         enabled:
-             type: boolean
-             default: true
-         hosts_nodes:
-             type: boolean
-             default: true
-         hosts_users:
-             type: boolean
-             default: true
-         is_public:
-             type: boolean
-             default: true
-         # location, longitude, latitude
-
-tosca.nodes.Slice:
-    derived_from: tosca.nodes.Root
-    capability:
-        slice:
-            type: tosca.capabilities.xos.Slice
-
-tosca.relationships.MemberOfSlice:
-    derived_from: tosca.relationships.Root
-    valid_target_types: [ tosca.capabilities.xos.Slice ]
-
-tosca.relationships.MemberOfService:
-    derived_from: tosca.relationships.Root
-    valid_target_types: [ tosca.capabilities.xos.Service ]
-
-tosca.relationships.MemberOfSite:
-    derived_from: tosca.relationships.Root
-    valid_target_types: [ tosca.capabilities.xos.Site ]
-
-tosca.relationships.TenantOfService:
-    derived_from: tosca.relationships.Root
-    valid_target_types: [ tosca.capabilities.xos.Service ]
-
-tosca.relationships.ControllerDeployment:
-    derived_from: tosca.relationships.Root
-    valid_target_types: [ tosca.capabilities.xos.Deployment ]
-
-tosca.relationships SiteDeployment:
-    derived_from: tosca.relationships.Root
-    valid_target_types: [ tosca.capabilities.xos.Deployment ]
-
-tosca.relationships.UsesController:
-    derived_from: tosca.relationships.Root
-    valid_target_types: [ tosca.capabilities.xos.Controller ]
-
-tosca.relationships.ConnectsToNetwork:
-    derived_from: tosca.relationships.Root
-    valid_target_types: [ tosca.capabilities.xos.Network ]
-
-#    tosca.relationships.OwnsNetwork:
-#        derived_from: tosca.relationships.Root
-#        valid_target_types: [ tosca.capabilities.xos.Network ]
-
-tosca.relationships.UsesNetworkTemplate:
-    derived_from: tosca.relationships.Root
-    valid_target_types: [ tosca.capabilities.xos.NetworkTemplate ]
-
-tosca.relationships.AdminPrivilege:
-    derived_from: tosca.relationships.Root
-    valid_target_types: [ tosca.capabilities.xos.Slice, tosca.capabiltys.xos.Site ]
-
-tosca.relationships.AccessPrivilege:
-    derived_from: tosca.relationships.Root
-    valid_target_types: [ tosca.capabilities.xos.Slice, tosca.capabiltys.xos.Site ]
-
-tosca.relationships.PIPrivilege:
-    derived_from: tosca.relationships.Root
-    valid_target_types: [ tosca.capabiltys.xos.Site ]
-
-tosca.relationships.TechPrivilege:
-    derived_from: tosca.relationships.Root
-    valid_target_types: [ tosca.capabiltys.xos.Site ]
-
-tosca.capabilities.xos.Service:
-    derived_from: tosca.capabilities.Root
-    description: An XOS Service
-
-tosca.capabilities.xos.Deployment:
-    derived_from: tosca.capabilities.Root
-    description: An XOS Deployment
-
-tosca.capabilities.xos.Controller:
-    derived_from: tosca.capabilities.Root
-    description: An XOS Controller
-
-tosca.capabilities.xos.Site:
-    derived_from: tosca.capabilities.Root
-    description: An XOS Site
-
-tosca.capabilities.xos.Slice:
-    derived_from: tosca.capabilities.Root
-    description: An XOS Slice
-
-tosca.capabilities.xos.NetworkTemplate:
-    derived_from: tosca.capabilities.Root
-    description: An XOS network template
-
-tosca.capabilities.xos.Network:
-    derived_from: tosca.capabilities.Root
-    description: An XOS network
-
-tosca.capabilities.xos.User:
-    derived_from: tosca.capabilities.Root
-    description: An XOS user
diff --git a/xos/tosca/destroy.py b/xos/tosca/destroy.py
index 5743234..968e450 100644
--- a/xos/tosca/destroy.py
+++ b/xos/tosca/destroy.py
@@ -1,8 +1,7 @@
 import os
 import sys
 
-# XXX - deal with what I think is a bug in OpenStack's tosca engine
-os.system("cat definitions/TOSCA_definition_1_0.yaml definitions/xos.yaml >  /opt/tosca/translator/toscalib/elements/TOSCA_definition_1_0.yaml")
+os.system("m4 custom_types/xos.m4 > custom_types/xos.yaml")
 
 # add the parent directory to sys.path
 import os,sys,inspect
diff --git a/xos/tosca/flavorselect.py b/xos/tosca/flavorselect.py
new file mode 100644
index 0000000..36024f9
--- /dev/null
+++ b/xos/tosca/flavorselect.py
@@ -0,0 +1,35 @@
+import os
+import sys
+
+from core.models import Slice,Sliver,User,Flavor,Node,Image
+
+class XOSFlavorSelector(object):
+    def __init__(self, user, mem_size=None, num_cpus=None, disk_size=None):
+        self.user = user
+        self.mem_size = self.get_mb(mem_size)
+        self.num_cpus = int(num_cpus)
+        self.disk_size = self.get_gb(disk_size)
+
+    def get_gb(self, s):
+        if "GB" in s:
+            return int(s.split("GB")[0].strip())
+        if "MB" in s:
+            return int(s.split("MB")[0].strip())/1024
+        return int(s)
+
+    def get_mb(self, s):
+        return self.get_gb(s) * 1024
+
+    def get_flavor(self):
+        flavor = "m1.tiny"
+        if (self.mem_size>512) or (self.disk_size>1):
+            flavor = "m1.small"
+        if (self.mem_size>2048) or (self.disk_size>20) or (self.num_cpus>1):
+            flavor = "m1.medium"
+        if (self.mem_size>4096) or (self.disk_size>40) or (self.num_cpus>2):
+            flavor = "m1.large"
+        if (self.mem_size>8192) or (self.disk_size>80) or (self.num_cpus>4):
+            flavor = "m1.xlarge"
+
+        return Flavor.objects.get(name=flavor)
+
diff --git a/xos/tosca/run.py b/xos/tosca/run.py
index d82aa4d..45a87ea 100644
--- a/xos/tosca/run.py
+++ b/xos/tosca/run.py
@@ -1,8 +1,7 @@
 import os
 import sys
 
-# XXX - deal with what I think is a bug in OpenStack's tosca engine
-os.system("cat definitions/TOSCA_definition_1_0.yaml definitions/xos.yaml >  /opt/tosca/translator/toscalib/elements/TOSCA_definition_1_0.yaml")
+os.system("m4 custom_types/xos.m4 > custom_types/xos.yaml")
 
 # add the parent directory to sys.path
 import os,sys,inspect
diff --git a/xos/tosca/samples/cord.yaml b/xos/tosca/samples/cord.yaml
index 7d51607..9a536c5 100644
--- a/xos/tosca/samples/cord.yaml
+++ b/xos/tosca/samples/cord.yaml
@@ -14,43 +14,31 @@
           - vcpe_tenant:
               node: service_vcpe
               relationship: tosca.relationships.IsTenantOf
+      properties:
+          view_url: /admin/cord/voltservice/$id$/
 
     service_vcpe:
-      type: tosca.nodes.Service
+      type: tosca.nodes.VcpeService
       requirements:
           - vbng_tenant:
               node: service_vbng
               relationship: tosca.relationships.IsTenantOf
+      properties:
+          view_url: /admin/cord/vcpeservice/$id$/
+          backend_network_label: hpc_client
 
     service_vbng:
       type: tosca.nodes.Service
+      properties:
+          view_url: /admin/cord/vbngservice/$id$/
+#          vbng_url: http://10.0.3.136:8181/onos/virtualbng/
 
-    mysite_volt:
-      description: vOLT Controller Slice
+    mysite_vcpe:
+      description: vCPE Controller Slice
       type: tosca.nodes.Slice
       requirements:
-          - volt_service:
+          - vcpe_service:
               node: service_volt
               relationship: tosca.relationships.MemberOfService
 
-    volt_controller:
-      type: tosca.nodes.Compute
-      capabilities:
-        # Host container properties
-        host:
-         properties:
-           num_cpus: 1
-           disk_size: 10 GB
-           mem_size: 4 MB
-        # Guest Operating System properties
-        os:
-          properties:
-            # host Operating System image properties
-            architecture: x86_64
-            type: linux
-            distribution: rhel
-            version: 6.5
-      requirements:
-          - slice:
-                node: mysite_volt
-                relationship: tosca.relationships.MemberOfSlice
+