validators for xoslib
diff --git a/planetstack/core/xoslib/static/js/xoslib/xos-validators.js b/planetstack/core/xoslib/static/js/xoslib/xos-validators.js
new file mode 100644
index 0000000..0c04274
--- /dev/null
+++ b/planetstack/core/xoslib/static/js/xoslib/xos-validators.js
@@ -0,0 +1,52 @@
+function xos_get_defaults() {
+ this.account = {"updated": null, "created": null, "deleted": false, "site": null, "backend_status": "Provisioning in progress", "enacted": null};
+ this.charge = {"updated": null, "slice": null, "created": null, "deleted": false, "object": null, "account": null, "date": null, "amount": 0.0, "state": "pending", "invoice": null, "coreHours": 0.0, "backend_status": "Provisioning in progress", "kind": "besteffort", "enacted": null};
+ this.dashboardView = {"updated": null, "name": "", "created": null, "deleted": false, "url": "", "backend_status": "Provisioning in progress", "enacted": null};
+ this.deployment = {"accessControl": "allow all", "updated": null, "admin_user": null, "name": "", "created": null, "deleted": false, "availability_zone": null, "backend_type": null, "auth_url": null, "admin_password": null, "backend_status": "Provisioning in progress", "admin_tenant": null, "enacted": null};
+ this.deploymentPrivilege = {"updated": null, "created": null, "deleted": false, "role": null, "user": null, "deployment": null, "backend_status": "Provisioning in progress", "enacted": null};
+ this.deploymentRole = {"updated": null, "created": null, "deleted": false, "role": "", "backend_status": "Provisioning in progress", "enacted": null};
+ this.flavor = {"updated": null, "description": null, "created": null, "deleted": false, "enacted": null, "default": false, "flavor": "", "backend_status": "Provisioning in progress", "order": 0, "name": ""};
+ this.image = {"updated": null, "name": "", "created": null, "deleted": false, "container_format": "", "disk_format": "", "path": null, "backend_status": "Provisioning in progress", "enacted": null};
+ this.imageDeployments = {"updated": null, "created": null, "deleted": false, "image": null, "deployment": null, "backend_status": "Provisioning in progress", "glance_image_id": null, "enacted": null};
+ this.invoice = {"updated": null, "created": null, "deleted": false, "account": null, "date": null, "backend_status": "Provisioning in progress", "enacted": null};
+ this.network = {"controllerParameters": null, "subnet": "", "updated": null, "name": "", "created": null, "subnet_id": null, "network_id": null, "labels": null, "deleted": false, "guaranteedBandwidth": 0, "controllerUrl": null, "topologyParameters": null, "router_id": null, "template": null, "owner": null, "backend_status": "Provisioning in progress", "ports": null, "permitAllSlices": false, "enacted": null};
+ this.networkDeployments = {"router_id": null, "subnet": "", "updated": null, "network": null, "created": null, "deleted": false, "subnet_id": null, "deployment": null, "backend_status": "Provisioning in progress", "net_id": null, "enacted": null};
+ this.networkParameter = {"updated": null, "created": null, "deleted": false, "object_id": null, "value": "", "content_type": null, "backend_status": "Provisioning in progress", "parameter": null, "enacted": null};
+ this.networkParameterType = {"updated": null, "description": "", "created": null, "deleted": false, "enacted": null, "backend_status": "Provisioning in progress", "name": ""};
+ this.networkSlice = {"updated": null, "slice": null, "network": null, "created": null, "deleted": false, "backend_status": "Provisioning in progress", "enacted": null};
+ this.networkSliver = {"updated": null, "network": null, "created": null, "deleted": false, "ip": null, "enacted": null, "backend_status": "Provisioning in progress", "port_id": null, "sliver": null};
+ this.networkTemplate = {"controllerKind": null, "updated": null, "backend_status": "Provisioning in progress", "description": null, "created": null, "deleted": false, "sharedNetworkName": null, "guaranteedBandwidth": 0, "visibility": "private", "enacted": null, "translation": "none", "sharedNetworkId": null, "topologyKind": "BigSwitch", "name": ""};
+ this.node = {"updated": null, "name": "", "created": null, "deleted": false, "site": null, "deployment": null, "backend_status": "Provisioning in progress", "enacted": null};
+ this.payment = {"updated": null, "created": null, "deleted": false, "account": null, "amount": 0.0, "date": "2014-11-25T19:20:14.905Z", "backend_status": "Provisioning in progress", "enacted": null};
+ this.planetStack = {"updated": null, "description": "PlanetStack", "created": null, "deleted": false, "backend_status": "Provisioning in progress", "enacted": null};
+ this.planetStackPrivilege = {"updated": null, "created": null, "deleted": false, "role": null, "user": null, "backend_status": "Provisioning in progress", "planetstack": 1, "enacted": null};
+ this.planetStackRole = {"updated": null, "created": null, "deleted": false, "role": "", "backend_status": "Provisioning in progress", "enacted": null};
+ this.project = {"updated": null, "name": "", "created": null, "deleted": false, "backend_status": "Provisioning in progress", "enacted": null};
+ this.reservation = {"updated": null, "slice": null, "created": null, "deleted": false, "startTime": null, "duration": 1, "backend_status": "Provisioning in progress", "enacted": null};
+ this.reservedResource = {"updated": null, "reservationSet": null, "created": null, "deleted": false, "resource": null, "enacted": null, "backend_status": "Provisioning in progress", "quantity": 1, "sliver": null};
+ this.role = {"updated": null, "description": "", "created": null, "deleted": false, "role": null, "content_type": null, "backend_status": "Provisioning in progress", "role_type": "", "enacted": null};
+ this.router = {"updated": null, "name": "", "created": null, "deleted": false, "owner": null, "backend_status": "Provisioning in progress", "enacted": null};
+ this.service = {"updated": null, "description": null, "created": null, "deleted": false, "enabled": true, "versionNumber": "", "published": true, "enacted": null, "backend_status": "Provisioning in progress", "name": ""};
+ this.serviceAttribute = {"updated": null, "name": "", "service": null, "created": null, "deleted": false, "value": "", "backend_status": "Provisioning in progress", "enacted": null};
+ this.serviceClass = {"updated": null, "membershipFee": 0, "membershipFeeMonths": 12, "created": null, "deleted": false, "description": "", "commitment": 365, "enacted": null, "backend_status": "Provisioning in progress", "upgradeRequiresApproval": false, "name": ""};
+ this.serviceResource = {"updated": null, "name": "", "bucketMaxSize": 0, "created": null, "deleted": false, "serviceClass": null, "maxUnitsDeployment": 1, "maxDuration": 1, "maxUnitsNode": 1, "cost": 0, "enacted": null, "backend_status": "Provisioning in progress", "bucketInRate": 0, "calendarReservable": true};
+ this.site = {"updated": null, "name": "", "created": null, "deleted": false, "enabled": true, "longitude": null, "site_url": null, "login_base": "", "location": "0,0", "latitude": null, "is_public": true, "backend_status": "Provisioning in progress", "abbreviated_name": "", "enacted": null};
+ this.siteCredential = {"updated": null, "name": "", "created": null, "deleted": false, "site": null, "key_id": "", "enacted": null, "backend_status": "Provisioning in progress", "enc_value": ""};
+ this.siteDeployments = {"updated": null, "created": null, "deleted": false, "tenant_id": null, "site": null, "deployment": null, "backend_status": "Provisioning in progress", "enacted": null};
+ this.sitePrivilege = {"updated": null, "created": null, "deleted": false, "site": null, "role": null, "user": null, "backend_status": "Provisioning in progress", "enacted": null};
+ this.siteRole = {"updated": null, "created": null, "deleted": false, "role": "", "backend_status": "Provisioning in progress", "enacted": null};
+ this.slice = {"updated": null, "imagePreference": "Ubuntu 12.04 LTS", "name": "", "service": null, "created": null, "deleted": false, "slice_url": "", "serviceClass": 1, "enabled": true, "site": null, "omf_friendly": false, "network": "Private Only", "max_slivers": 10, "mountDataSets": "GenBank", "enacted": null, "backend_status": "Provisioning in progress", "creator": null, "description": ""};
+ this.sliceCredential = {"updated": null, "slice": null, "name": "", "created": null, "deleted": false, "key_id": "", "enacted": null, "backend_status": "Provisioning in progress", "enc_value": ""};
+ this.sliceDeployments = {"router_id": null, "updated": null, "slice": null, "network_id": null, "created": null, "deleted": false, "tenant_id": null, "subnet_id": null, "deployment": null, "backend_status": "Provisioning in progress", "enacted": null};
+ this.slicePrivilege = {"updated": null, "slice": null, "created": null, "deleted": false, "role": null, "user": null, "backend_status": "Provisioning in progress", "enacted": null};
+ this.sliceRole = {"updated": null, "created": null, "deleted": false, "role": "", "backend_status": "Provisioning in progress", "enacted": null};
+ this.sliceTag = {"updated": null, "slice": null, "name": "", "created": null, "deleted": false, "value": "", "backend_status": "Provisioning in progress", "enacted": null};
+ this.sliver = {"node": null, "instance_id": null, "updated": null, "slice": null, "deploymentNetwork": null, "name": "", "created": null, "deleted": false, "ip": null, "image": null, "creator": null, "numberCores": 0, "instance_name": null, "userData": null, "backend_status": "Provisioning in progress", "flavor": 2, "enacted": null};
+ this.tag = {"updated": null, "name": "", "service": null, "created": null, "deleted": false, "value": "", "object_id": null, "content_type": null, "backend_status": "Provisioning in progress", "enacted": null};
+ this.usableObject = {"updated": null, "name": "", "created": null, "deleted": false, "backend_status": "Provisioning in progress", "enacted": null};
+ this.user = {"username": "Something", "public_key": null, "updated": null, "password": "", "is_readonly": false, "firstname": "", "user_url": null, "deleted": false, "lastname": "", "created": null, "is_active": true, "site": null, "phone": null, "is_staff": true, "last_login": "2014-11-25T19:20:14.986Z", "is_admin": true, "timezone": "America/New_York", "backend_status": "Provisioning in progress", "email": "", "enacted": null};
+ this.userCredential = {"updated": null, "name": "", "created": null, "deleted": false, "user": null, "key_id": "", "enacted": null, "backend_status": "Provisioning in progress", "enc_value": ""};
+ this.userDashboardView = {"updated": null, "created": null, "deleted": false, "dashboardView": null, "user": null, "backend_status": "Provisioning in progress", "order": 0, "enacted": null};
+ this.userDeployments = {"updated": null, "created": null, "deleted": false, "kuser_id": null, "user": null, "deployment": null, "backend_status": "Provisioning in progress", "enacted": null};
+};
+xosdefaults = new xos_get_defaults();
diff --git a/planetstack/core/xoslib/tools/make_validators.py b/planetstack/core/xoslib/tools/make_validators.py
new file mode 100644
index 0000000..ad5377c
--- /dev/null
+++ b/planetstack/core/xoslib/tools/make_validators.py
@@ -0,0 +1,41 @@
+import os
+import sys
+os.chdir("/opt/planetstack")
+sys.path.append("/opt/planetstack")
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "planetstack.settings")
+import django
+import core.models
+from django.db import models
+django.setup()
+from django.forms.models import model_to_dict
+import inspect
+from django.core import serializers
+import json
+
+print "function xos_get_defaults() {"
+
+for c in dir(core.models):
+ c = getattr(core.models,c)
+ if inspect.isclass(c) and issubclass(c, models.Model):
+ c=c()
+ classname = c.__class__.__name__
+ classname = classname[0].lower() + classname[1:]
+
+ if (classname in ["plCoreBase", "singletonModel"]):
+ continue
+
+ fieldNames = [f.name for f in c._meta.fields]
+
+ fields = json.loads(serializers.serialize("json",[c],fields=fieldNames))[0]["fields"]
+
+ for f in fields.keys():
+ if f in ['created', 'updated', 'enacted']:
+ fields[f] = None
+
+ fields_json = json.dumps(fields)
+
+ print " this." + classname + " = " + fields_json + ";"
+
+print "};"
+print "xosdefaults = new xos_get_defaults();"
+