SEBA-271 Fix xproto field numbers not passed through

Change-Id: Ib5abee510e1a02f025d3011699d9f34d59e201c1
diff --git a/VERSION b/VERSION
index ea4bd0f..1b5105d 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.1.13
+2.1.14
diff --git a/containers/chameleon/Dockerfile.chameleon b/containers/chameleon/Dockerfile.chameleon
index b544cab..c5bddd5 100644
--- a/containers/chameleon/Dockerfile.chameleon
+++ b/containers/chameleon/Dockerfile.chameleon
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 # xosproject/chameleon
-FROM xosproject/xos-base:2.1.13
+FROM xosproject/xos-base:2.1.14
 
 # xos-base already has protoc and dependencies installed
 
diff --git a/containers/xos/Dockerfile.client b/containers/xos/Dockerfile.client
index 4f853ed..693f806 100644
--- a/containers/xos/Dockerfile.client
+++ b/containers/xos/Dockerfile.client
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 # xosproject/xos-client
-FROM xosproject/xos-libraries:2.1.13
+FROM xosproject/xos-libraries:2.1.14
 
 # Install XOS client
 COPY xos/xos_client /tmp/xos_client
diff --git a/containers/xos/Dockerfile.libraries b/containers/xos/Dockerfile.libraries
index 5992f3e..4e024e9 100644
--- a/containers/xos/Dockerfile.libraries
+++ b/containers/xos/Dockerfile.libraries
@@ -12,7 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-FROM xosproject/xos-base:2.1.13
+FROM xosproject/xos-base:2.1.14
 
 # Add libraries
 COPY lib /opt/xos/lib
diff --git a/containers/xos/Dockerfile.synchronizer-base b/containers/xos/Dockerfile.synchronizer-base
index 6605d36..6d82d6e 100644
--- a/containers/xos/Dockerfile.synchronizer-base
+++ b/containers/xos/Dockerfile.synchronizer-base
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 # xosproject/xos-synchronizer-base
-FROM xosproject/xos-client:2.1.13
+FROM xosproject/xos-client:2.1.14
 
 COPY xos/synchronizers/new_base /opt/xos/synchronizers/new_base
 COPY xos/xos/logger.py /opt/xos/xos/logger.py
diff --git a/containers/xos/Dockerfile.xos-core b/containers/xos/Dockerfile.xos-core
index caf2621..d120388 100644
--- a/containers/xos/Dockerfile.xos-core
+++ b/containers/xos/Dockerfile.xos-core
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 # xosproject/xos-core
-FROM xosproject/xos-libraries:2.1.13
+FROM xosproject/xos-libraries:2.1.14
 
 # Install XOS
 ADD xos /opt/xos
diff --git a/lib/xos-genx/xos-genx-tests/helpers.py b/lib/xos-genx/xos-genx-tests/helpers.py
index 232cae1..ca73402 100644
--- a/lib/xos-genx/xos-genx-tests/helpers.py
+++ b/lib/xos-genx/xos-genx-tests/helpers.py
@@ -23,6 +23,7 @@
 
 # Store in this class the args to pass at the generator
 class FakeArgs:
+    verbosity=0
     pass
 
 class XProtoTestHelpers:
diff --git a/lib/xos-genx/xosgenx/generator.py b/lib/xos-genx/xosgenx/generator.py
index cc00742..dc1ff9e 100644
--- a/lib/xos-genx/xosgenx/generator.py
+++ b/lib/xos-genx/xosgenx/generator.py
@@ -42,7 +42,7 @@
             v = Proto2XProto()
             ast.accept(v)
 
-        v = XOS2Jinja()
+        v = XOS2Jinja(args)
         ast.accept(v)
         return v
 
diff --git a/lib/xos-genx/xosgenx/jinja2_extensions/base.py b/lib/xos-genx/xosgenx/jinja2_extensions/base.py
index 1293863..561aeea 100644
--- a/lib/xos-genx/xosgenx/jinja2_extensions/base.py
+++ b/lib/xos-genx/xosgenx/jinja2_extensions/base.py
@@ -120,7 +120,10 @@
         if accessor:
             base_fields = xproto_base_fields(table[accessor], table)
 
-            model_fields = table[accessor]['fields']
+            model_fields = [x.copy() for x in table[accessor]['fields']]
+            for field in model_fields:
+                field["accessor"] = accessor
+
             fields.extend(base_fields)
             fields.extend(model_fields)
 
@@ -132,6 +135,53 @@
 
     return fields
 
+def xproto_fields(m, table):
+    """ Generate the full list of models for the xproto message `m` including fields from the classes it inherits.
+
+        Inserts the special field "id" at the very beginning.
+
+        Each time we descend a new level of inheritance, increment the offset field numbers by 100. The base
+        class's fields will be numbered from 1-99, the first descendant will be number 100-199, the second
+        descdendant numbered from 200-299, and so on. This assumes any particular model as at most 100
+        fields.
+    """
+
+    model_fields = [x.copy() for x in m["fields"]]
+    for field in model_fields:
+        field["accessor"] = m["fqn"]
+
+    fields = xproto_base_fields(m, table) + model_fields
+
+    # The "id" field is a special field. Every model has one. Put it up front and pretend it's part of the
+
+    id_field = {'type': 'int32', 'name': 'id', 'options': {}, "id": "1", "accessor": fields[0]["accessor"]}
+
+    fields = [id_field] + fields
+
+    # Walk through the list of fields. They will be in depth-first search order from the base model forward. Each time
+    # the model changes, offset the protobuf field numbers by 100.
+    offset = 0
+    last_accessor = fields[0]["accessor"]
+    for field in fields:
+        if (field["accessor"] != last_accessor):
+            last_accessor = field["accessor"]
+            offset += 100
+        field_id = int(field["id"])
+        if (field_id < 1) or (field_id >= 100):
+            raise Exception("Only field numbers from 1 to 99 are permitted, field %s in model %s" % (field["name"], field["accessor"]))
+        field["id"] = int(field["id"]) + offset
+
+    # Check for duplicates
+    fields_by_number = {}
+    for field in fields:
+        id = field["id"]
+        dup = fields_by_number.get(id)
+        if dup:
+            raise Exception("Field %s has duplicate number %d with field %s in model %s" % (field["name"], id, dup["name"], field["accessor"]))
+        fields_by_number[id] = field
+
+    return fields
+
 def xproto_base_rlinks(m, table):
     links = []
 
@@ -146,6 +196,38 @@
 
     return links
 
+def xproto_rlinks(m, table):
+    """ Return the reverse links for the xproto message `m`.
+
+        If the link includes a reverse_id, then it will be used for the protobuf field id. If there is no
+        reverse_id, then one will automatically be allocated started at id 1900. It is incouraged that all links
+        include reverse_ids, so that field identifiers are deterministic across all protobuf messages.
+    """
+
+    index = 1900
+    links = xproto_base_rlinks(m, table) + m["rlinks"]
+
+    links = [x for x in links if ("+" not in x["src_port"]) and ("+" not in x["dst_port"])]
+
+    for link in links:
+        if link["reverse_id"]:
+            link["id"] = int(link["reverse_id"])
+        else:
+            link["id"] = index
+            index += 1
+
+    # check for duplicates
+    links_by_number={}
+    for link in links:
+        id = link["id"]
+        dup=links_by_number.get(id)
+        if dup:
+            raise Exception("Field %s has duplicate number %d with field %s in model %s" % (link["src_port"], id, link["src_port"], m["name"]))
+        links_by_number[id] = link
+
+    return links
+
+
 def xproto_base_links(m, table):
     links = []
 
diff --git a/lib/xos-genx/xosgenx/targets/fieldlist.xtarget b/lib/xos-genx/xosgenx/targets/fieldlist.xtarget
new file mode 100644
index 0000000..3c0dea4
--- /dev/null
+++ b/lib/xos-genx/xosgenx/targets/fieldlist.xtarget
@@ -0,0 +1,11 @@
+
+{% for object in proto.messages|sort(attribute='name') %}
+{{ object.name }}
+{%- for field in xproto_fields(object, proto.message_table) | sort(attribute='id') %}
+  {{ field.name }}, {{ field.id }}, {{ field.accessor }}
+{%- endfor %}
+{%- for field in xproto_rlinks(object, proto.message_table) | sort(attribute='id') %}
+  {{ field.src_port }}_ids, {{ field.id }}, {{ field.accessor }}
+{%- endfor %}
+
+{% endfor %}
diff --git a/lib/xos-genx/xosgenx/targets/protoapi.xtarget b/lib/xos-genx/xosgenx/targets/protoapi.xtarget
index 183bacd..2311b98 100644
--- a/lib/xos-genx/xosgenx/targets/protoapi.xtarget
+++ b/lib/xos-genx/xosgenx/targets/protoapi.xtarget
@@ -20,23 +20,23 @@
     option (contentTypeId) = "{{ xproto_unquote(xproto_first_non_empty([object.options.name, object.options.app_label, options.name, context.app_label])) }}.{{ object.name | lower }}";
     {%- endif %}
     {%- set id_field = {'type':'int32', 'name':'id', 'options':{}} -%}
-  {%- for field in (xproto_base_fields(object, proto.message_table) + object.fields + [id_field]) | sort(attribute='name')%}
+  {%- for field in xproto_fields(object, proto.message_table) | sort(attribute='id')%}
   {%- if field.options.type == "link" and field.options.link_type == "manytomany" %}
-    repeated int32 {{ field.name }}_ids = {{ loop.index }} [(manyToManyForeignKey).modelName = "{{ field.options.model }}"];
+    repeated int32 {{ field.name }}_ids = {{ field.id }} [(manyToManyForeignKey).modelName = "{{ field.options.model }}"];
   {%- else %}
     oneof {{ field.name }}_present {
-      {{ xproto_api_type(field) }} {{ field.name }}{% if field.link -%}_id{% endif %} = {{ loop.index }}{{ xproto_api_opts(field) }};
+      {{ xproto_api_type(field) }} {{ field.name }}{% if field.link -%}_id{% endif %} = {{ field.id }} {{ xproto_api_opts(field) }};
     }
   {%- endif -%}
   {%- endfor -%}
 
-  {%- for ref in xproto_base_rlinks(object, proto.message_table) + object.rlinks | sort(attribute='src_port') %}
+  {%- for ref in xproto_rlinks(object, proto.message_table) | sort(attribute='id') %}
   {%- if '+' not in ref.src_port and '+' not in ref.dst_port %}
-    repeated int32 {{ ref.src_port }}_ids  = {{ loop.index + 100 }} [(reverseForeignKey).modelName = "{{ ref.peer.name }}"];
+    repeated int32 {{ ref.src_port }}_ids  = {{ ref["id"] }} [(reverseForeignKey).modelName = "{{ ref.peer.name }}"];
   {%- endif -%}
   {%- endfor %}
-  string class_names = 201;
-  string self_content_type_id = 202;
+  string class_names = 2046;
+  string self_content_type_id = 2047;
 }
 
 message {{ xproto_pluralize(object) }} {
diff --git a/lib/xos-genx/xosgenx/xos2jinja.py b/lib/xos-genx/xosgenx/xos2jinja.py
index 42e83c3..aca2468 100644
--- a/lib/xos-genx/xosgenx/xos2jinja.py
+++ b/lib/xos-genx/xosgenx/xos2jinja.py
@@ -72,41 +72,6 @@
             count += 1
     return count
 
-def compute_rlinks(messages, message_dict):
-    rev_links = {}
-
-    link_opposite = {
-        'manytomany': 'manytomany',
-        'manytoone': 'onetomany',
-        'onetoone': 'onetoone',
-        'onetomany': 'manytoone'
-    }
-
-    for m in messages:
-        for l in m['links']:
-            rlink = copy.deepcopy(l)
-
-            rlink['_type'] = 'rlink'  # An implicit link, not declared in the model
-            rlink['src_port'] = l['dst_port']
-            rlink['dst_port'] = l['src_port']
-            rlink['peer'] = {'name': m['name'], 'package': m['package'], 'fqn': m['fqn']}
-            rlink['link_type'] = link_opposite[l['link_type']]
-
-            try:
-                try:
-                    rev_links[l['peer']['fqn']].append(rlink)
-                except TypeError:
-                    pass
-            except KeyError:
-                rev_links[l['peer']['fqn']] = [rlink]
-
-    for m in messages:
-        try:
-            m['rlinks'] = rev_links[m['name']]
-            message_dict[m['name']]['rlinks'] = m['rlinks']
-        except KeyError:
-            pass
-
 
 def name_to_value(obj):
     try:
@@ -129,7 +94,7 @@
     in addition to traversing it '''
 
 class XOS2Jinja(Visitor):
-    def __init__(self):
+    def __init__(self, args):
         super(XOS2Jinja, self).__init__()
 
         self.stack = Stack()
@@ -145,6 +110,7 @@
         self.verbose = 0
         self.first_field = True
         self.first_method = True
+        self.args = args
 
     def visit_PolicyDefinition(self, obj):
         if self.package:
@@ -241,6 +207,11 @@
             except AttributeError:
                 s['peer'] = obj.name
 
+        try:
+            s['reverse_id'] = obj.reverse_id.pval
+        except AttributeError:
+            s['reverse_id'] = obj.reverse_id
+
         s['_type'] = 'link'
         s['options'] = {'modifier': 'optional'}
 
@@ -397,7 +368,7 @@
 
             messages.insert(0, m)
 
-        compute_rlinks(messages, self.models)
+        self.compute_rlinks(messages, self.models)
 
         self.messages = messages
         return True
@@ -406,3 +377,45 @@
         count = self.count_stack.pop()
         self.count_stack.push(count + 1)
         return True
+
+    def compute_rlinks(self, messages, message_dict):
+        rev_links = {}
+
+        link_opposite = {
+            'manytomany': 'manytomany',
+            'manytoone': 'onetomany',
+            'onetoone': 'onetoone',
+            'onetomany': 'manytoone'
+        }
+
+        for m in messages:
+            for l in m['links']:
+                rlink = copy.deepcopy(l)
+
+                rlink['_type'] = 'rlink'  # An implicit link, not declared in the model
+                rlink['src_port'] = l['dst_port']
+                rlink['dst_port'] = l['src_port']
+                rlink['peer'] = {'name': m['name'], 'package': m['package'], 'fqn': m['fqn']}
+                rlink['link_type'] = link_opposite[l['link_type']]
+                rlink["reverse_id"] = l['reverse_id']
+
+                if (not l['reverse_id']) and (self.args.verbosity >= 1):
+                    print >> sys.stderr, "WARNING: Field %s in model %s has no reverse_id" % (l["src_port"], m["name"])
+
+                if l["reverse_id"] and ((int(l["reverse_id"]) < 1000) or (int(l["reverse_id"]) >= 1900)):
+                    raise Exception("reverse id for field %s in model %s should be between 1000 and 1899" % (l["src_port"], m["name"]))
+
+                try:
+                    try:
+                        rev_links[l['peer']['fqn']].append(rlink)
+                    except TypeError:
+                        pass
+                except KeyError:
+                    rev_links[l['peer']['fqn']] = [rlink]
+
+        for m in messages:
+            try:
+                m['rlinks'] = rev_links[m['name']]
+                message_dict[m['name']]['rlinks'] = m['rlinks']
+            except KeyError:
+                pass
diff --git a/lib/xos-genx/xosgenx/xosgen.py b/lib/xos-genx/xosgenx/xosgen.py
index ec1ba68..8259d58 100755
--- a/lib/xos-genx/xosgenx/xosgen.py
+++ b/lib/xos-genx/xosgenx/xosgen.py
@@ -27,6 +27,7 @@
 parse.add_argument('--kvpairs', dest='kv', action='store',default=None, help='Key value pairs to make available to the target')
 parse.add_argument('--write-to-file', dest='write_to_file', choices = ['single', 'model', 'target'], action='store',default=None, help='Single output file (single) or output file per model (model) or let target decide (target)')
 parse.add_argument('--version', action='version', version=__version__)
+parse.add_argument("-v", "--verbosity", action="count", default=0, help="increase output verbosity")
 
 group = parse.add_mutually_exclusive_group()
 group.add_argument('--dest-file', dest='dest_file', action='store',default=None, help='Output file name (if write-to-file is set to single)')
diff --git a/scripts/xos_dev_reqs.txt b/scripts/xos_dev_reqs.txt
index 5f1f9c3..b306f5a 100644
--- a/scripts/xos_dev_reqs.txt
+++ b/scripts/xos_dev_reqs.txt
@@ -12,7 +12,7 @@
 netaddr==0.7.19
 networkx==1.11
 nose2==0.7.4
-plyxproto==3.0.1
+plyxproto==3.1.0
 pykwalify==1.6.1
 requests-mock==1.5.0
 tosca-parser==0.9.0
diff --git a/xos/core/models/core.xproto b/xos/core/models/core.xproto
index 7ede452..3805053 100644
--- a/xos/core/models/core.xproto
+++ b/xos/core/models/core.xproto
@@ -9,28 +9,29 @@
      option custom_header = "xosbase_header";
      option abstract = True;
 
-     required string created = 1 [content_type = "date", auto_now_add = True, help_text = "Time this model was created"];
-     required string updated = 2 [default = "now()", content_type = "date", help_text = "Time this model was changed by a non-synchronizer"];
-     optional string enacted = 3 [null = True, content_type = "date", blank = True, default = None, help_text = "When synced, set to the timestamp of the data that was synced"];
-     optional string policed = 4 [null = True, content_type = "date", blank = True, default = None, help_text = "When policed, set to the timestamp of the data that was policed"];
-     optional string backend_register = 5 [default = "{}", max_length = 1024, feedback_state = True];
-     required bool backend_need_delete = 6 [default = False, blank = True];
-     required bool backend_need_reap = 7 [default = False, blank = True];
-     required string backend_status = 8 [default = "Provisioning in progress", max_length = 1024, null = True, feedback_state = True];
-     required int32 backend_code = 9 [default = 0, feedback_state = True];
-     required bool deleted = 10 [default = False, blank = True];
+     // field 1 is reserved for "id"
+     required string created = 2 [content_type = "date", auto_now_add = True, help_text = "Time this model was created"];
+     required string updated = 3 [default = "now()", content_type = "date", help_text = "Time this model was changed by a non-synchronizer"];
+     optional string enacted = 4 [null = True, content_type = "date", blank = True, default = None, help_text = "When synced, set to the timestamp of the data that was synced"];
+     optional string policed = 5 [null = True, content_type = "date", blank = True, default = None, help_text = "When policed, set to the timestamp of the data that was policed"];
+     optional string backend_register = 6 [default = "{}", max_length = 1024, feedback_state = True];
+     required bool backend_need_delete = 7 [default = False, blank = True];
+     required bool backend_need_reap = 8 [default = False, blank = True];
+     required string backend_status = 9 [default = "Provisioning in progress", max_length = 1024, null = True, feedback_state = True];
+     required int32 backend_code = 10 [default = 0, feedback_state = True];
+     required bool deleted = 11 [default = False, blank = True];
      required bool write_protect = 12 [default = False, blank = True];
      required bool lazy_blocked = 13 [default = False, blank = True];
      required bool no_sync = 14 [default = False, blank = True];
      required bool no_policy = 15 [default = False, blank = True];
      optional string policy_status = 16 [default = "Policy in process", max_length = 1024, feedback_state = True];
-     optional int32 policy_code = 16 [default = 0, feedback_state = True];
-     required string leaf_model_name = 17 [null = False, max_length = 1024, help_text = "The most specialized model in this chain of inheritance, often defined by a service developer"];
-     required bool backend_need_delete_policy = 18 [default = False, help_text = "True if delete model_policy must be run before object can be reaped", blank = True];
-     required bool xos_managed = 19 [default = True, help_text = "True if xos is responsible for creating/deleting this object", blank = True, gui_hidden = True];
-     optional string backend_handle = 20 [max_length = 1024, feedback_state = True, blank=True, null=True, help_text = "Handle used by the backend to track this object", gui_hidden = True];
-     optional string changed_by_step = 21 [null = True, content_type = "date", blank = True, default = None, gui_hidden = True, help_text = "Time this model was changed by a sync step"];
-     optional string changed_by_policy = 22 [null = True, content_type = "date", blank = True, default = None, gui_hidden = True, help_text = "Time this model was changed by a model policy"];
+     optional int32 policy_code = 17 [default = 0, feedback_state = True];
+     required string leaf_model_name = 18 [null = False, max_length = 1024, help_text = "The most specialized model in this chain of inheritance, often defined by a service developer"];
+     required bool backend_need_delete_policy = 19 [default = False, help_text = "True if delete model_policy must be run before object can be reaped", blank = True];
+     required bool xos_managed = 20 [default = True, help_text = "True if xos is responsible for creating/deleting this object", blank = True, gui_hidden = True];
+     optional string backend_handle = 21 [max_length = 1024, feedback_state = True, blank=True, null=True, help_text = "Handle used by the backend to track this object", gui_hidden = True];
+     optional string changed_by_step = 22 [null = True, content_type = "date", blank = True, default = None, gui_hidden = True, help_text = "Time this model was changed by a sync step"];
+     optional string changed_by_policy = 23 [null = True, content_type = "date", blank = True, default = None, gui_hidden = True, help_text = "Time this model was changed by a model policy"];
 }
 
 // The calling user represents the user being accessed, or is a site admin.
@@ -48,45 +49,46 @@
      option skip_django = True;
      option description = "An XOS User";
 
-     required string email = 1 [db_index = True, max_length = 255, null = False, blank = False, tosca_key=True];
-     required string username = 2 [default = "Something", max_length = 255, content_type = "stripped", blank = False, null = False, db_index = False];
-     required string password = 3 [default = "Something", max_length = 255, blank = False, null = False, db_index = False];
-     optional string last_login = 4 [db_index = False, null = True, content_type = "date", blank = True];
-     required string firstname = 5 [max_length = 200, content_type = "stripped", blank = False, help_text = "person's given name", null = False, db_index = False];
-     required string lastname = 6 [max_length = 200, content_type = "stripped", blank = False, help_text = "person's surname", null = False, db_index = False];
-     optional string phone = 7 [max_length = 100, content_type = "stripped", blank = True, help_text = "phone number contact", null = True, db_index = False];
-     optional string user_url = 8 [db_index = False, max_length = 200, null = True, content_type = "url", blank = True];
-     required manytoone site->Site:users = 9 [help_text = "Site this user will be homed too", null = False, db_index = True, blank = False];
-     optional string public_key = 10 [help_text = "Public key string", max_length = 1024, null = True, db_index = False, blank = True, varchar = True];
-     required bool is_active = 11 [default = True, null = False, db_index = False, blank = True];
-     required bool is_admin = 12 [default = False, null = False, db_index = False, blank = True];
-     required bool is_staff = 13 [default = True, null = False, db_index = False, blank = True];
-     required bool is_readonly = 14 [default = False, null = False, db_index = False, blank = True];
-     required bool is_registering = 15 [default = False, null = False, db_index = False, blank = True];
-     required bool is_appuser = 16 [default = False, null = False, db_index = False, blank = True];
-     optional string login_page = 17 [max_length = 200, content_type = "stripped", blank = True, help_text = "send this user to a specific page on login", null = True, db_index = False];
-     required string created = 18 [db_index = False, null = False, content_type = "date", blank = True];
-     required string updated = 19 [db_index = False, null = False, content_type = "date", blank = True];
-     optional string enacted = 20 [db_index = False, null = True, content_type = "date", blank = False];
-     optional string policed = 21 [db_index = False, null = True, content_type = "date", blank = False];
-     required string backend_status = 22 [default = "Provisioning in progress", max_length = 1024, content_type = "stripped", blank = False, null = False, db_index = False];
-     required int32 backend_code = 34 [default = 0];
-     required bool backend_need_delete = 23 [default = False, null = False, db_index = False, blank = True];
-     required bool backend_need_reap = 24 [default = False, null = False, db_index = False, blank = True];
-     required bool deleted = 25 [default = False, null = False, db_index = False, blank = True];
-     required bool write_protect = 26 [default = False, null = False, db_index = False, blank = True];
-     required bool lazy_blocked = 27 [default = False, null = False, db_index = False, blank = True];
-     required bool no_sync = 28 [default = False, null = False, db_index = False, blank = True];
-     required bool no_policy = 29 [default = False, null = False, db_index = False, blank = True];
-     required string timezone = 30 [default = "America/New_York", max_length = 100, blank = False, null = False, db_index = False];
-     optional string policy_status = 32 [default = "0 - Policy in process", max_length = 1024];
-     optional int32 policy_code = 35 [default = 0];
-     required string leaf_model_name = 33 [null = False, max_length = 1024, help_text = "The most specialized model in this chain of inheritance, often defined by a service developer"];
-     required bool backend_need_delete_policy = 34 [default = False, help_text = "True if delete model_policy must be run before object can be reaped", blank = True];
-     required bool xos_managed = 35 [default = True, help_text = "True if xos is responsible for creating/deleting this object", blank = True, gui_hidden = True];
-     optional string backend_handle = 36 [max_length = 1024, feedback_state = True, blank=True, null=True, help_text = "Handle used by the backend to track this object", gui_hidden = True];
-     optional string changed_by_step = 37 [null = True, content_type = "date", blank = True, default = None, gui_hidden = True, help_text = "Time this model was changed by a sync step"];
-     optional string changed_by_policy = 38 [null = True, content_type = "date", blank = True, default = None, gui_hidden = True, help_text = "Time this model was changed by a model policy"];
+     // field 1 is reserved for "id"
+     required string email = 2 [db_index = True, max_length = 255, null = False, blank = False, tosca_key=True];
+     required string username = 3 [default = "Something", max_length = 255, content_type = "stripped", blank = False, null = False, db_index = False];
+     required string password = 4 [default = "Something", max_length = 255, blank = False, null = False, db_index = False];
+     optional string last_login = 5 [db_index = False, null = True, content_type = "date", blank = True];
+     required string firstname = 6 [max_length = 200, content_type = "stripped", blank = False, help_text = "person's given name", null = False, db_index = False];
+     required string lastname = 7 [max_length = 200, content_type = "stripped", blank = False, help_text = "person's surname", null = False, db_index = False];
+     optional string phone = 8 [max_length = 100, content_type = "stripped", blank = True, help_text = "phone number contact", null = True, db_index = False];
+     optional string user_url = 9 [db_index = False, max_length = 200, null = True, content_type = "url", blank = True];
+     required manytoone site->Site:users = 10:1001 [help_text = "Site this user will be homed too", null = False, db_index = True, blank = False];
+     optional string public_key = 11 [help_text = "Public key string", max_length = 1024, null = True, db_index = False, blank = True, varchar = True];
+     required bool is_active = 12 [default = True, null = False, db_index = False, blank = True];
+     required bool is_admin = 13 [default = False, null = False, db_index = False, blank = True];
+     required bool is_staff = 14 [default = True, null = False, db_index = False, blank = True];
+     required bool is_readonly = 15 [default = False, null = False, db_index = False, blank = True];
+     required bool is_registering = 16 [default = False, null = False, db_index = False, blank = True];
+     required bool is_appuser = 17 [default = False, null = False, db_index = False, blank = True];
+     optional string login_page = 18 [max_length = 200, content_type = "stripped", blank = True, help_text = "send this user to a specific page on login", null = True, db_index = False];
+     required string created = 19 [db_index = False, null = False, content_type = "date", blank = True];
+     required string updated = 20 [db_index = False, null = False, content_type = "date", blank = True];
+     optional string enacted = 21 [db_index = False, null = True, content_type = "date", blank = False];
+     optional string policed = 22 [db_index = False, null = True, content_type = "date", blank = False];
+     required string backend_status = 23 [default = "Provisioning in progress", max_length = 1024, content_type = "stripped", blank = False, null = False, db_index = False];
+     required int32 backend_code = 24 [default = 0];
+     required bool backend_need_delete = 25 [default = False, null = False, db_index = False, blank = True];
+     required bool backend_need_reap = 26 [default = False, null = False, db_index = False, blank = True];
+     required bool deleted = 27 [default = False, null = False, db_index = False, blank = True];
+     required bool write_protect = 28 [default = False, null = False, db_index = False, blank = True];
+     required bool lazy_blocked = 29 [default = False, null = False, db_index = False, blank = True];
+     required bool no_sync = 30 [default = False, null = False, db_index = False, blank = True];
+     required bool no_policy = 31 [default = False, null = False, db_index = False, blank = True];
+     required string timezone = 32 [default = "America/New_York", max_length = 100, blank = False, null = False, db_index = False];
+     optional string policy_status = 33 [default = "0 - Policy in process", max_length = 1024];
+     optional int32 policy_code = 34 [default = 0];
+     required string leaf_model_name = 35 [null = False, max_length = 1024, help_text = "The most specialized model in this chain of inheritance, often defined by a service developer"];
+     required bool backend_need_delete_policy = 36 [default = False, help_text = "True if delete model_policy must be run before object can be reaped", blank = True];
+     required bool xos_managed = 37 [default = True, help_text = "True if xos is responsible for creating/deleting this object", blank = True, gui_hidden = True];
+     optional string backend_handle = 38 [max_length = 1024, feedback_state = True, blank=True, null=True, help_text = "Handle used by the backend to track this object", gui_hidden = True];
+     optional string changed_by_step = 39 [null = True, content_type = "date", blank = True, default = None, gui_hidden = True, help_text = "Time this model was changed by a sync step"];
+     optional string changed_by_policy = 40 [null = True, content_type = "date", blank = True, default = None, gui_hidden = True, help_text = "Time this model was changed by a model policy"];
 }
 
 // A user may give a permission that he has to another user
@@ -115,12 +117,12 @@
      required string gateway_mac = 4 [db_index = False, max_length = 32, help_text="Gateway MAC address for this AddressPool"];
      required string cidr = 5 [db_index = False, max_length = 32, help_text="Subnet for this AddressPool"];
      optional string inuse = 6 [db_index = False, null = True, blank = True, varchar = True, help_text="Space-separated list of inuse addresses"];
-     optional manytoone service->Service:addresspools = 7 [db_index = True, null = True, blank = True, help_text="Service this AddressPool belongs to"];
+     optional manytoone service->Service:addresspools = 7:1001 [db_index = True, null = True, blank = True, help_text="Service this AddressPool belongs to"];
 }
 
 message ComputeServiceInstance (ServiceInstance) {
-     required manytoone slice->Slice:computeserviceinstances = 1 [db_index = True, null = False, blank = False, help_text = "Slice that controls this ServiceInstance"];
-     required manytoone image->Image:computeserviceinstances = 2 [db_index = True, null = False, blank = False, help_text = "Image used to instantiate this ServiceInstance"];
+     required manytoone slice->Slice:computeserviceinstances = 1:1001 [db_index = True, null = False, blank = False, help_text = "Slice that controls this ServiceInstance"];
+     required manytoone image->Image:computeserviceinstances = 2:1001 [db_index = True, null = False, blank = False, help_text = "Image used to instantiate this ServiceInstance"];
 }
 
 // Admins at a deployment have access to controllers at those deployments
@@ -144,12 +146,12 @@
      optional string rabbit_host = 9 [max_length = 200, content_type = "stripped", blank = True, help_text = "IP address of rabbitmq server at this controller", null = True, db_index = False];
      optional string rabbit_user = 10 [max_length = 200, content_type = "stripped", blank = True, help_text = "Username of rabbitmq server at this controller", null = True, db_index = False];
      optional string rabbit_password = 11 [max_length = 200, content_type = "stripped", blank = True, help_text = "Password of rabbitmq server at this controller", null = True, db_index = False];
-     required manytoone deployment->Deployment:controllerdeployments = 12 [db_index = True, null = False, blank = False];
+     required manytoone deployment->Deployment:controllerdeployments = 12:1001 [db_index = True, null = False, blank = False];
 }
 
 message ControllerImages (XOSBase) {
-     required manytoone image->Image:controllerimages = 1 [db_index = True, null = False, blank = False, unique_with = "controller"];
-     required manytoone controller->Controller:controllerimages = 2 [db_index = True, null = False, blank = False];
+     required manytoone image->Image:controllerimages = 1:1002 [db_index = True, null = False, blank = False, unique_with = "controller"];
+     required manytoone controller->Controller:controllerimages = 2:1001 [db_index = True, null = False, blank = False];
      optional string glance_image_id = 3 [max_length = 200, content_type = "stripped", blank = True, help_text = "Glance image id", null = True, db_index = False];
 }
 
@@ -194,8 +196,8 @@
 
 
 message ControllerNetwork::controller_network_policy (XOSBase) {
-     required manytoone network->Network:controllernetworks = 1 [db_index = True, null = False, blank = False, unique_with = "controller"];
-     required manytoone controller->Controller:controllernetworks = 2 [db_index = True, null = False, blank = False];
+     required manytoone network->Network:controllernetworks = 1:1001 [db_index = True, null = False, blank = False, unique_with = "controller"];
+     required manytoone controller->Controller:controllernetworks = 2:1002 [db_index = True, null = False, blank = False];
      required string subnet = 3 [db_index = False, max_length = 32, null = False, blank = True];
      required string start_ip = 4 [db_index = False, max_length = 32, null = False, blank = True];
      required string stop_ip = 5 [db_index = False, max_length = 32, null = False, blank = True];
@@ -211,14 +213,14 @@
 }
 
 message ControllerSite (XOSBase) {
-     required manytoone site->Site:controllersite = 1 [db_index = True, null = False, blank = False, unique_with="controller", tosca_key = True];
-     optional manytoone controller->Controller:controllersite = 2 [db_index = True, null = True, blank = True, tosca_key = True];
+     required manytoone site->Site:controllersite = 1:1002 [db_index = True, null = False, blank = False, unique_with="controller", tosca_key = True];
+     optional manytoone controller->Controller:controllersite = 2:1003 [db_index = True, null = True, blank = True, tosca_key = True];
      optional string tenant_id = 3 [max_length = 200, content_type = "stripped", blank = True, help_text = "Keystone tenant id", null = True, db_index = True];
 }
 
 message ControllerSitePrivilege (XOSBase) {
-     required manytoone controller->Controller:controllersiteprivileges = 1 [db_index = True, null = False, blank = False, unique_with = "site_privilege"];
-     required manytoone site_privilege->SitePrivilege:controllersiteprivileges = 2 [db_index = True, null = False, blank = False, unique_with = "role_id"];
+     required manytoone controller->Controller:controllersiteprivileges = 1:1004 [db_index = True, null = False, blank = False, unique_with = "site_privilege"];
+     required manytoone site_privilege->SitePrivilege:controllersiteprivileges = 2:1001 [db_index = True, null = False, blank = False, unique_with = "role_id"];
      optional string role_id = 3 [max_length = 200, content_type = "stripped", blank = True, help_text = "Keystone id", null = True, db_index = True];
 }
 
@@ -227,14 +229,14 @@
          | *slice_policy(slice) >
 
 message ControllerSlice::controller_slice_policy (XOSBase) {
-     required manytoone controller->Controller:controllerslices = 1 [db_index = True, null = False, blank = False, unique_with = "slice"];
-     required manytoone slice->Slice:controllerslices = 2 [db_index = True, null = False, blank = False];
+     required manytoone controller->Controller:controllerslices = 1:1005 [db_index = True, null = False, blank = False, unique_with = "slice"];
+     required manytoone slice->Slice:controllerslices = 2:1002 [db_index = True, null = False, blank = False];
      optional string tenant_id = 3 [max_length = 200, content_type = "stripped", blank = True, help_text = "Keystone tenant id", null = True, db_index = False];
 }
 
 message ControllerSlicePrivilege (XOSBase) {
-     required manytoone controller->Controller:controllersliceprivileges = 1 [db_index = True, null = False, blank = False, unique_with = "slice_privilege"];
-     required manytoone slice_privilege->SlicePrivilege:controllersliceprivileges = 2 [db_index = True, null = False, blank = False];
+     required manytoone controller->Controller:controllersliceprivileges = 1:1006 [db_index = True, null = False, blank = False, unique_with = "slice_privilege"];
+     required manytoone slice_privilege->SlicePrivilege:controllersliceprivileges = 2:1001 [db_index = True, null = False, blank = False];
      optional string role_id = 3 [max_length = 200, content_type = "stripped", blank = True, help_text = "Keystone id", null = True, db_index = True];
 }
 
@@ -243,8 +245,8 @@
          | (ctx.read_access & *user_policy(user)) >
 
 message ControllerUser::controller_user_policy (XOSBase) {
-     required manytoone user->User:controllerusers = 1 [db_index = True, null = False, blank = False];
-     required manytoone controller->Controller:controllersusers = 2 [db_index = True, null = False, blank = False, unique_with = "user"];
+     required manytoone user->User:controllerusers = 1:1001 [db_index = True, null = False, blank = False];
+     required manytoone controller->Controller:controllersusers = 2:1007 [db_index = True, null = False, blank = False, unique_with = "user"];
      optional string kuser_id = 3 [max_length = 200, content_type = "stripped", blank = True, help_text = "Keystone user id", null = True, db_index = False];
 }
 
@@ -281,8 +283,8 @@
 >
 
 message ImageDeployments (XOSBase) {
-     required manytoone image->Image:imagedeployments = 1 [db_index = True, null = False, blank = False, unique_with = "deployment"];
-     required manytoone deployment->Deployment:imagedeployments = 2 [db_index = True, null = False, blank = False];
+     required manytoone image->Image:imagedeployments = 1:1003 [db_index = True, null = False, blank = False, unique_with = "deployment"];
+     required manytoone deployment->Deployment:imagedeployments = 2:1002 [db_index = True, null = False, blank = False];
 }
 
 policy instance_creator < obj.creator >
@@ -301,17 +303,17 @@
      required string name = 3 [max_length = 200, content_type = "stripped", blank = False, help_text = "Instance name", null = False, db_index = False];
      optional string instance_name = 4 [max_length = 200, content_type = "stripped", blank = True, help_text = "OpenStack generated name", null = True, db_index = False, feedback_state = True];
      optional string ip = 5 [max_length = 39, content_type = "ip", blank = True, help_text = "Instance ip address", null = True, db_index = False, gui_hidden = True];
-     required manytoone image->Image:instances = 6 [db_index = True, null = False, blank = False];
-     optional manytoone creator->User:instances = 7 [db_index = True, null = True, blank = True];
-     required manytoone slice->Slice:instances = 8 [db_index = True, null = False, blank = False];
-     required manytoone deployment->Deployment:instance_deployment = 9 [db_index = True, null = False, blank = False];
-     required manytoone node->Node:instances = 10 [db_index = True, null = False, blank = False];
+     required manytoone image->Image:instances = 6:1004 [db_index = True, null = False, blank = False];
+     optional manytoone creator->User:instances = 7:1002 [db_index = True, null = True, blank = True];
+     required manytoone slice->Slice:instances = 8:1003 [db_index = True, null = False, blank = False];
+     required manytoone deployment->Deployment:instance_deployment = 9:1003 [db_index = True, null = False, blank = False];
+     required manytoone node->Node:instances = 10:1001 [db_index = True, null = False, blank = False];
      required int32 numberCores = 11 [help_text = "Number of cores for instance", default = 0, null = False, db_index = False, blank = False];
-     required manytoone flavor->Flavor:instance = 12 [help_text = "Flavor of this instance", null = False, db_index = True, blank = False];
+     required manytoone flavor->Flavor:instance = 12:1001 [help_text = "Flavor of this instance", null = False, db_index = True, blank = False];
      optional string userData = 13 [help_text = "user_data passed to instance during creation", null = True, db_index = False, blank = True, varchar = True];
      required string isolation = 14 [default = "vm", choices = "(('vm', 'Virtual Machine'), ('container', 'Container'), ('container_vm', 'Container In VM'))", max_length = 30, blank = False, null = False, db_index = False];
      optional string volumes = 15 [help_text = "Comma-separated list of directories to expose to parent context", null = True, db_index = False, blank = True];
-     optional manytoone parent->Instance:instance = 16 [help_text = "Parent Instance for containers nested inside of VMs", null = True, db_index = True, blank = True];
+     optional manytoone parent->Instance:instance = 16:1001 [help_text = "Parent Instance for containers nested inside of VMs", null = True, db_index = True, blank = True];
 }
 
 
@@ -319,24 +321,24 @@
 
 message Network::network_policy (XOSBase) {
      required string name = 1 [db_index = False, max_length = 32, null = False, blank = False, unique = True];
-     required manytoone template->NetworkTemplate:network = 2 [db_index = True, null = False, blank = False];
+     required manytoone template->NetworkTemplate:network = 2:1001 [db_index = True, null = False, blank = False];
      required string subnet = 3 [db_index = False, max_length = 32, null = False, blank = True];
      required string start_ip = 4 [db_index = False, max_length = 32, null = False, blank = True];
      required string end_ip = 5 [db_index = False, max_length = 32, null = False, blank = True];
      optional string ports = 6 [db_index = False, max_length = 1024, null = True, blank = True];
      optional string labels = 7 [db_index = False, max_length = 1024, null = True, blank = True];
-     required manytoone owner->Slice:ownedNetworks = 8 [help_text = "Slice that owns control of this Network", null = False, db_index = True, blank = False];
+     required manytoone owner->Slice:ownedNetworks = 8:1004 [help_text = "Slice that owns control of this Network", null = False, db_index = True, blank = False];
      required bool permit_all_slices = 10 [default = False, null = False, db_index = False, blank = True];
      required bool autoconnect = 17 [help_text = "This network can be autoconnected to the slice that owns it", default = True, null = False, db_index = False, blank = True];
-     required manytomany permitted_slices->Slice/Network_permitted_slices:availableNetworks = 18 [db_index = False, blank = True];
+     required manytomany permitted_slices->Slice/Network_permitted_slices:availableNetworks = 18:1005 [db_index = False, blank = True];
 }
 
 
 message NetworkParameter (XOSBase) {
-     required manytoone parameter->NetworkParameterType:networkparameters = 1 [help_text = "The type of the parameter", null = False, db_index = True, blank = False];
+     required manytoone parameter->NetworkParameterType:networkparameters = 1:1001 [help_text = "The type of the parameter", null = False, db_index = True, blank = False];
      required string value = 2 [help_text = "The value of this parameter", max_length = 1024, null = False, db_index = False, blank = False];
      required string content_type = 4 [max_length = 1024, content_type = "stripped", blank = False, help_text = "Content type id linked to this network parameter", null = False, db_index = False];
-     required uint32 object_id = 4 [db_index = False, null = False, blank = False, help_text = "Object linked to this NetworkParameter"];
+     required uint32 object_id = 5 [db_index = False, null = False, blank = False, help_text = "Object linked to this NetworkParameter"];
 }
 
 
@@ -350,8 +352,8 @@
 
 message NetworkSlice::network_slice_policy (XOSBase) {
      option validators = "network_slice_validator:Slice {obj.slice.name} is not allowed to connect to networks {obj.network}";
-     required manytoone network->Network:networkslices = 1 [db_index = True, null = False, blank = False, unique_with = "slice", tosca_key=True];
-     required manytoone slice->Slice:networkslices = 2 [db_index = True, null = False, blank = False, tosca_key=True];
+     required manytoone network->Network:networkslices = 1:1002 [db_index = True, null = False, blank = False, unique_with = "slice", tosca_key=True];
+     required manytoone slice->Slice:networkslices = 2:1006 [db_index = True, null = False, blank = False, tosca_key=True];
 }
 
 message NetworkTemplate (XOSBase) {
@@ -371,7 +373,7 @@
 
 message Node::node_policy (XOSBase) {
      required string name = 1 [max_length = 200, content_type = "stripped", blank = False, help_text = "Name of the Node", null = False, db_index = False, unique = True];
-     required manytoone site_deployment->SiteDeployment:nodes = 2 [db_index = True, null = False, blank = False];
+     required manytoone site_deployment->SiteDeployment:nodes = 2:1001 [db_index = True, null = False, blank = False];
      optional string bridgeId = 3 [max_length = 200, content_type = "stripped", blank = True, help_text = "Bridge Id", null = True, db_index = False];
      optional string dataPlaneIntf = 4 [max_length = 200, content_type = "stripped", blank = True, help_text = "Dataplane Interface", null = True, db_index = False];
      optional string dataPlaneIp = 5 [max_length = 200, content_type = "stripped", blank = True, help_text = "Dataplane Ip", null = True, db_index = False];
@@ -379,24 +381,24 @@
 }
 message NodeLabel (XOSBase) {
      required string name = 1 [max_length = 200, content_type = "stripped", blank = False, help_text = "label name", null = False, db_index = False, unique = True];
-     required manytomany node->Node/NodeLabel_node:nodelabels = 2 [db_index = False, blank = True];
+     required manytomany node->Node/NodeLabel_node:nodelabels = 2:1002 [db_index = False, blank = True];
 }
 
 policy port_policy < *instance_policy(instance) & *network_policy(network) >
 
 message Port::port_policy (XOSBase) {
-     required manytoone network->Network:links = 1 [db_index = True, null = False, blank = False, unique_with = "instance", help_text = "Network bound to this port"];
-     optional manytoone instance->Instance:ports = 2 [db_index = True, null = True, blank = True, help_text = "Instance bound to this port"];
+     required manytoone network->Network:links = 1:1003 [db_index = True, null = False, blank = False, unique_with = "instance", help_text = "Network bound to this port"];
+     optional manytoone instance->Instance:ports = 2:1002 [db_index = True, null = True, blank = True, help_text = "Instance bound to this port"];
      optional string ip = 3 [max_length = 39, content_type = "ip", blank = True, help_text = "Instance ip address", null = True, db_index = False];
      optional string port_id = 4 [help_text = "Neutron port id", max_length = 256, null = True, db_index = False, blank = True];
      optional string mac = 5 [help_text = "MAC address associated with this port", max_length = 256, null = True, db_index = False, blank = True];
      required bool xos_created = 6 [default = False, null = False, db_index = False, blank = True];
-     optional manytoone service_instance->ServiceInstance:ports = 2 [db_index = True, null = True, blank = True, help_text = "ServiceInstance bound to this port"];
+     optional manytoone service_instance->ServiceInstance:ports = 7:1001 [db_index = True, null = True, blank = True, help_text = "ServiceInstance bound to this port"];
 }
 
 message Principal (XOSBase) {
      required string name = 1 [max_length = 128, null = False, db_index = True, blank = False, help_text = "The name of this principal"];
-     required manytoone trust_domain->TrustDomain:principals = 2 [db_index = True, null = False, blank = False, help_text = "Trust domain this principal resides in"];
+     required manytoone trust_domain->TrustDomain:principals = 2:1001 [db_index = True, null = False, blank = False, help_text = "Trust domain this principal resides in"];
 }
 
 message Role (XOSBase) {
@@ -426,30 +428,23 @@
      required int32 external_port = 2 [blank = False, help_text = "external port number"];
      required int32 internal_port = 3 [blank = False, help_text = "internal port number"];
      required string protocol = 4 [max_length = 32, null = False, db_index = False, blank = False, default="TCP", help_text = "Protocol"];
-     required manytoone service->Service:serviceports = 5 [null = False, db_index = True, blank = False, help_text = "The Service this ServicePort is associated with"];
+     required manytoone service->Service:serviceports = 5:1002 [null = False, db_index = True, blank = False, help_text = "The Service this ServicePort is associated with"];
 }
 
 message ServiceAttribute (XOSBase) {
      required string name = 1 [help_text = "Attribute Name", max_length = 128, null = False, db_index = False, blank = False, unique_with="service"];
      required string value = 2 [help_text = "Attribute Value", null = False, db_index = False, blank = False, varchar = True];
-     required manytoone service->Service:serviceattributes = 3 [help_text = "The Service this attribute is associated with", null = False, db_index = True, blank = False];
+     required manytoone service->Service:serviceattributes = 3:1003 [help_text = "The Service this attribute is associated with", null = False, db_index = True, blank = False];
 }
 
 
 message ServiceDependency (XOSBase) {
-     required manytoone provider_service->Service:provided_dependencies = 1 [help_text = "The service that provides this dependency", null=False, db_index = True, blank=False, tosca_key=True];
-     required manytoone subscriber_service->Service:subscribed_dependencies = 2 [help_text = "The services that subscribes to this dependency", null=False, db_index=True, blank=False, tosca_key=True];
+     required manytoone provider_service->Service:provided_dependencies = 1:1004 [help_text = "The service that provides this dependency", null=False, db_index = True, blank=False, tosca_key=True];
+     required manytoone subscriber_service->Service:subscribed_dependencies = 2:1005 [help_text = "The services that subscribes to this dependency", null=False, db_index=True, blank=False, tosca_key=True];
      required string connect_method = 3 [max_length = 30, help_text = "method to connect the two services", default="none", choices = "(('none', 'None'), ('private', 'Private'), ('public', 'Public'))"];
 }
 
 
-message ServiceMonitoringAgentInfo (XOSBase) {
-     required string name = 1 [help_text = "Monitoring Agent Name", max_length = 128, null = False, db_index = False, blank = False, unique_with="service"];
-     optional manytoone service->Service:servicemonitoringagents = 2 [help_text = "The Service this attribute is associated with", null = True, db_index = True, blank = True];
-     required string target_uri = 3 [help_text = "Monitoring collector URI to be used by agents to publish the data", null = False, db_index = False, blank = False, varchar = True];
-}
-
-
 message Site::site_policy (XOSBase) {
      required string name = 1 [max_length = 200, content_type = "stripped", blank = False, help_text = "Name for this Site", null = False, db_index = False, unique = True];
      optional string site_url = 2 [max_length = 512, content_type = "url", blank = True, help_text = "Site's Home URL Page", null = True, db_index = False];
@@ -465,16 +460,16 @@
 
 
 message SiteDeployment (XOSBase) {
-     required manytoone site->Site:sitedeployments = 1 [db_index = True, null = False, blank = False, unique_with = "deployment", tosca_key=True];
-     required manytoone deployment->Deployment:sitedeployments = 2 [db_index = True, null = False, blank = False, unique_with = "controller", tosca_key=True];
-     optional manytoone controller->Controller:sitedeployments = 3 [db_index = True, null = True, blank = True];
+     required manytoone site->Site:sitedeployments = 1:1003 [db_index = True, null = False, blank = False, unique_with = "deployment", tosca_key=True];
+     required manytoone deployment->Deployment:sitedeployments = 2:1004 [db_index = True, null = False, blank = False, unique_with = "controller", tosca_key=True];
+     optional manytoone controller->Controller:sitedeployments = 3:1008 [db_index = True, null = True, blank = True];
      optional string availability_zone = 4 [max_length = 200, content_type = "stripped", blank = True, help_text = "OpenStack availability zone", null = True, db_index = False];
 }
 
 message SitePrivilege (XOSBase) {
-     required manytoone user->User:siteprivileges = 1 [db_index = True, null = False, blank = False];
-     required manytoone site->Site:siteprivileges = 2 [db_index = True, null = False, blank = False, tosca_key=True];
-     required manytoone role->SiteRole:siteprivileges = 3 [db_index = True, null = False, blank = False, tosca_key=True];
+     required manytoone user->User:siteprivileges = 1:1003 [db_index = True, null = False, blank = False];
+     required manytoone site->Site:siteprivileges = 2:1004 [db_index = True, null = False, blank = False, tosca_key=True];
+     required manytoone role->SiteRole:siteprivileges = 3:1001 [db_index = True, null = False, blank = False, tosca_key=True];
 }
 
 
@@ -492,27 +487,27 @@
      required string name = 1 [max_length = 80, content_type = "stripped", blank = False, help_text = "The Name of the Slice", null = False, db_index = False, unique = True];
      required bool enabled = 2 [help_text = "Status for this Slice", default = True, null = False, db_index = False, blank = True];
      required string description = 4 [help_text = "High level description of the slice and expected activities", max_length = 1024, null = False, db_index = False, blank = True, varchar = True];
-     required manytoone site->Site:slices = 6 [help_text = "The Site this Slice belongs to", null = False, db_index = True, blank = False];
+     required manytoone site->Site:slices = 6:1005 [help_text = "The Site this Slice belongs to", null = False, db_index = True, blank = False];
      required int32 max_instances = 7 [default = 10, null = False, db_index = False, blank = False];
-     optional manytoone service->Service:slices = 8 [db_index = True, null = True, blank = True];
+     optional manytoone service->Service:slices = 8:1006 [db_index = True, null = True, blank = True];
      optional string network = 9 [blank = True, max_length = 256, null = True, db_index = False, choices = "((None, 'Default'), ('host', 'Host'), ('bridged', 'Bridged'), ('noauto', 'No Automatic Networks'))"];
      optional string exposed_ports = 10 [db_index = False, max_length = 256, null = True, blank = True];
-     optional manytoone creator->User:slices = 12 [db_index = True, null = False, blank = False];
-     optional manytoone default_flavor->Flavor:slices = 13 [db_index = True, null = True, blank = True];
-     optional manytoone default_image->Image:slices = 14 [db_index = True, null = True, blank = True];
-     optional manytoone default_node->Node:slices = 15 [db_index = True, null = True, blank = True];
+     optional manytoone creator->User:slices = 12:1004 [db_index = True, null = False, blank = False];
+     optional manytoone default_flavor->Flavor:slices = 13:1002 [db_index = True, null = True, blank = True];
+     optional manytoone default_image->Image:slices = 14:1005 [db_index = True, null = True, blank = True];
+     optional manytoone default_node->Node:slices = 15:1003 [db_index = True, null = True, blank = True];
      optional string mount_data_sets = 16 [default = "GenBank", max_length = 256, content_type = "stripped", blank = True, null = True, db_index = False];
      required string default_isolation = 17 [default = "vm", choices = "(('vm', 'Virtual Machine'), ('container', 'Container'), ('container_vm', 'Container In VM'))", max_length = 30, blank = False, null = False, db_index = False];
-     optional manytoone trust_domain->TrustDomain:slices = 12 [db_index = True, null = False, blank = False, help_text = "Trust domain this slice resides in"];
-     optional manytoone principal->Principal:slices = 12 [db_index = True, null = False, blank = False, help_text = "Principal this slice may use to interact with other components"];
-     optional int32 controller_replica_count = 13 [default = 0, null = False, db_index = False, blank = False, help_text = "Replica count, controller-dependent"];
-     optional string controller_kind = 14 [max_length = 256, content_type = "stripped", blank = True, help_text = "Type of controller, vim-dependent", null = True, db_index = False];
+     optional manytoone trust_domain->TrustDomain:slices = 18:1002 [db_index = True, null = False, blank = False, help_text = "Trust domain this slice resides in"];
+     optional manytoone principal->Principal:slices = 19:1001 [db_index = True, null = False, blank = False, help_text = "Principal this slice may use to interact with other components"];
+     optional int32 controller_replica_count = 20 [default = 0, null = False, db_index = False, blank = False, help_text = "Replica count, controller-dependent"];
+     optional string controller_kind = 21 [max_length = 256, content_type = "stripped", blank = True, help_text = "Type of controller, vim-dependent", null = True, db_index = False];
 }
 
 message SlicePrivilege (XOSBase) {
-     required manytoone user->User:sliceprivileges = 1 [db_index = True, null = False, blank = False, unique_with = "slice"];
-     required manytoone slice->Slice:sliceprivileges = 2 [db_index = True, null = False, blank = False, unique_with = "role"];
-     required manytoone role->SliceRole:sliceprivileges = 3 [db_index = True, null = False, blank = False];
+     required manytoone user->User:sliceprivileges = 1:1005 [db_index = True, null = False, blank = False, unique_with = "slice"];
+     required manytoone slice->Slice:sliceprivileges = 2:1007 [db_index = True, null = False, blank = False, unique_with = "role"];
+     required manytoone role->SliceRole:sliceprivileges = 3:1002 [db_index = True, null = False, blank = False];
 }
 
 
@@ -523,7 +518,7 @@
 policy tag_policy < ctx.user.is_admin >
 
 message Tag::tag_policy (XOSBase) {
-     required manytoone service->Service:tags = 1 [help_text = "The Service this Tag is associated with", null = False, db_index = True, blank = False];
+     required manytoone service->Service:tags = 1:1007 [help_text = "The Service this Tag is associated with", null = False, db_index = True, blank = False];
      required string name = 2 [help_text = "The name of this tag", max_length = 128, null = False, db_index = True, blank = False];
      required string value = 3 [max_length = 1024, content_type = "stripped", blank = False, help_text = "The value of this tag", null = False, db_index = False];
      required string content_type = 4 [max_length = 1024, content_type = "stripped", blank = False, help_text = "Content type id linked to this tag", null = False, db_index = False];
@@ -536,36 +531,36 @@
 }
 
 message ServiceInterface (XOSBase) {
-     required manytoone service->Service:service_interfaces = 1 [db_index = True, null = False, blank = False, tosca_key=True];
-     required manytoone interface_type->InterfaceType:service_interfaces = 2 [db_index = True, null = False, blank = False, tosca_key=True];
+     required manytoone service->Service:service_interfaces = 1:1008 [db_index = True, null = False, blank = False, tosca_key=True];
+     required manytoone interface_type->InterfaceType:service_interfaces = 2:1001 [db_index = True, null = False, blank = False, tosca_key=True];
 }
 
 message ServiceInstance (XOSBase, AttributeMixin) {
      optional string name = 1 [db_index = False, max_length = 200, null = True, content_type = "stripped", blank = True];
-     required manytoone owner->Service:service_instances = 2 [db_index = True, null = False, blank = False];
+     required manytoone owner->Service:service_instances = 2:1009 [db_index = True, null = False, blank = False];
      optional string service_specific_id = 3 [db_index = False, max_length = 30, null = True, content_type = "stripped", blank = True, gui_hidden = True];
      optional string service_specific_attribute = 10 [db_index = False, null = True, blank = True, varchar = True, gui_hidden = True];
      optional uint32 link_deleted_count = 11 [default = 0, help_text = "Incremented each time a provided_link is deleted from this ServiceInstance", gui_hidden = True];
-     optional manytoone master_serviceinstance->ServiceInstance:child_serviceinstances = 12 [help_text = "The master service instance that set this service instance up", gui_hidden = True, blank = True];
+     optional manytoone master_serviceinstance->ServiceInstance:child_serviceinstances = 12:1002 [help_text = "The master service instance that set this service instance up", gui_hidden = True, blank = True];
 }
 
 message ServiceInstanceLink (XOSBase) {
-     required manytoone provider_service_instance->ServiceInstance:provided_links = 1 [db_index = True, null = False, blank = False, tosca_key=True];
-     optional manytoone provider_service_interface->ServiceInterface:provided_links = 2 [db_index = True, null = True, blank = True];
-     optional manytoone subscriber_service_instance->ServiceInstance:subscribed_links = 3 [db_index = True, null = True, blank = True];
-     optional manytoone subscriber_service->Service:subscribed_links = 4 [db_index = True, null = True, blank = True, tosca_key_one_of=subscriber_service_instance];
-     optional manytoone subscriber_network->Network:subscribed_links = 5 [db_index = True, null = True, blank = True, tosca_key_one_of=subscriber_service_instance];
+     required manytoone provider_service_instance->ServiceInstance:provided_links = 1:1003 [db_index = True, null = False, blank = False, tosca_key=True];
+     optional manytoone provider_service_interface->ServiceInterface:provided_links = 2:1004 [db_index = True, null = True, blank = True];
+     optional manytoone subscriber_service_instance->ServiceInstance:subscribed_links = 3:1005 [db_index = True, null = True, blank = True];
+     optional manytoone subscriber_service->Service:subscribed_links = 4:1010 [db_index = True, null = True, blank = True, tosca_key_one_of=subscriber_service_instance];
+     optional manytoone subscriber_network->Network:subscribed_links = 5:1004 [db_index = True, null = True, blank = True, tosca_key_one_of=subscriber_service_instance];
 }
 
 message ServiceInstanceAttribute (XOSBase) {
      required string name = 1 [help_text = "Attribute Name", max_length = 128, null = False, db_index = False, blank = False, unique_with="service_instance"];
      required string value = 2 [help_text = "Attribute Value", null = False, db_index = False, blank = False];
-     required manytoone service_instance->ServiceInstance:service_instance_attributes = 3 [help_text = "The Tenant this attribute is associated with", null = False, db_index = True, blank = False];
+     required manytoone service_instance->ServiceInstance:service_instance_attributes = 3:1006 [help_text = "The Tenant this attribute is associated with", null = False, db_index = True, blank = False];
 }
 
 message TenantWithContainer (ServiceInstance) {
-     optional manytoone instance->Instance:+ = 1 [help_text = "Instance used by this Tenant", null = True, db_index = True, blank = True];
-     optional manytoone creator->User:+ = 2 [help_text = "Creator of this Tenant", null = True, db_index = True, blank = True];
+     optional manytoone instance->Instance:+ = 1:1003 [help_text = "Instance used by this Tenant", null = True, db_index = True, blank = True];
+     optional manytoone creator->User:+ = 2:1006 [help_text = "Creator of this Tenant", null = True, db_index = True, blank = True];
      optional string external_hostname = 3 [max_length = 30, content_type = "stripped", blank = True, help_text = "External host name", null = True, db_index = False];
      optional string external_container = 4 [max_length = 30, content_type = "stripped", blank = True, help_text = "External host name", null = True, db_index = False];
      optional string node_label = 5 [max_length = 30, content_type = "stripped", blank = True, help_text = "Node constraint", null = True, db_index = False];
@@ -573,7 +568,7 @@
 
 message TrustDomain (XOSBase) {
      required string name = 1 [max_length = 255, null = False, db_index = True, blank = False, help_text = "Name of this trust domain"];
-     required manytoone owner->Service:owned_trust_domains = 2 [null = False, db_index = True, blank = False, help_text = "Service partioned by this trust domain"];
+     required manytoone owner->Service:owned_trust_domains = 2:1011 [null = False, db_index = True, blank = False, help_text = "Service partioned by this trust domain"];
 }
 
 message XOSCore (XOSBase) {
diff --git a/xos/coreapi/dynamicbuild.py b/xos/coreapi/dynamicbuild.py
index 3a4c8e4..37b5af2 100644
--- a/xos/coreapi/dynamicbuild.py
+++ b/xos/coreapi/dynamicbuild.py
@@ -234,6 +234,7 @@
         is_service = manifest["name"] != 'core'
 
         args = Args()
+        args.verbosity = 0
         args.output = manifest["dest_dir"]
         args.attic = os.path.join(manifest["dir"], 'attic')
         args.files = xproto_filenames
@@ -250,6 +251,7 @@
 
         # Generate security checks
         class SecurityArgs:
+            verbosity = 0
             output = manifest["dest_dir"]
             target = 'django-security.xtarget'
             dest_file = 'security.py'