resolve merge conflicts
diff --git a/cloudlab-init.sh b/cloudlab-init.sh
index b946249..468271d 100755
--- a/cloudlab-init.sh
+++ b/cloudlab-init.sh
@@ -73,6 +73,6 @@
if [ "$CORD" -ne 0 ]
then
- DOCKER=$( docker ps|grep $IMAGE|awk '{print $NF}' )
- docker exec $DOCKER bash -c "cd /opt/xos/tosca; python run.py padmin@vicci.org samples/cord-cloudlab.yaml"
+ DOCKER=$( sudo docker ps|grep $IMAGE|awk '{print $NF}' )
+ sudo docker exec $DOCKER bash -c "cd /opt/xos/tosca; python run.py padmin@vicci.org samples/cord-cloudlab.yaml"
fi
diff --git a/xos/core/admin.py b/xos/core/admin.py
index 93486a2..d5246ae 100644
--- a/xos/core/admin.py
+++ b/xos/core/admin.py
@@ -1041,6 +1041,7 @@
normal_inlines = [SlicePrivilegeInline, InstanceInline, TagInline, ReservationInline, SliceNetworkInline]
inlines = normal_inlines
admin_inlines = [ControllerSliceInline]
+ suit_form_includes = (('slice_instance_tab.html', 'bottom', 'instances'),)
user_readonly_fields = fieldList
@@ -1119,6 +1120,12 @@
inline.model.caller = request.user
yield inline.get_formset(request, obj)
+ def add_extra_context(self, request, extra_context):
+ super(SliceAdmin, self).add_extra_context(request, extra_context)
+ # set context["slice_id"] to the PK passed in the URL to this view
+ if len(request.resolver_match.args)>0:
+ extra_context["slice_id"] = request.resolver_match.args[0]
+
def UNUSED_get_inline_instances(self, request, obj=None):
# HACK for CORD to do something special on vcpe slice page
# this was a good idea, but failed miserably, as something still
@@ -1291,11 +1298,7 @@
self.readonly_fields = ('backend_status_text', 'ssh_command', 'all_ips_string', 'slice', 'flavor', 'image', 'node')
for inline in self.get_inline_instances(request, obj):
- # hide MyInline in the add view
- if obj is None:
- continue
- if isinstance(inline, InstanceInline):
- inline.model.caller = request.user
+ # dead code was eliminated here
yield inline.get_formset(request, obj)
#def save_model(self, request, obj, form, change):
diff --git a/xos/core/models/network.py b/xos/core/models/network.py
index 1258d76..fe60fce 100644
--- a/xos/core/models/network.py
+++ b/xos/core/models/network.py
@@ -207,9 +207,6 @@
return qs
class Port(PlCoreBase):
- # Please use "Port" instead of "NetworkInstance". NetworkInstance will soon be
- # removed.
-
network = models.ForeignKey(Network,related_name='links')
instance = models.ForeignKey(Instance, null=True, blank=True, related_name='ports')
ip = models.GenericIPAddressField(help_text="Instance ip address", blank=True, null=True)
diff --git a/xos/core/templates/slice_instance_tab.html b/xos/core/templates/slice_instance_tab.html
new file mode 100644
index 0000000..f3890c8
--- /dev/null
+++ b/xos/core/templates/slice_instance_tab.html
@@ -0,0 +1,41 @@
+{% if slice_id %}
+
+<a href="/admin/core/instance/add/?_to_field=id&slice={{ slice_id }}" class="add-another" id="add_instance_advanced"
+onclick="return showAddInstancePopup(this);">
+Add Instance using expert settings window
+</a>
+<!-- div id="instance_advanced" style="display: node;" onchange="console.log('changed');" -->
+<input type="hidden" id="instance_advanced" name="instance_advanced" onchange="console.log('changed');" value="initial">
+
+<script>
+
+// ugly - poll for djange to change "instance_advanced", and it it does, then refresh the
+// page so the instance list gets updated.
+var last_instance_advanced = $("#instance_advanced").val();
+checkInstanceAdvanced = function() {
+ cur = $("#instance_advanced").val();
+ if (cur != last_instance_advanced) {
+ last_instance_advanced = cur;
+ location.reload();
+ }
+};
+
+setInterval(function() { checkInstanceAdvanced(); }, 1000);
+
+function showAddInstancePopup(triggeringLink) {
+ var name = triggeringLink.id.replace(/^add_/, '');
+ name = id_to_windowname(name);
+ var href = triggeringLink.href;
+ if (href.indexOf('?') == -1) {
+ href += '?_popup=1';
+ } else {
+ href += '&_popup=1';
+ }
+ var win = window.open(href, name, 'height=500,width=1080,resizable=yes,scrollbars=yes');
+ win.focus();
+ return false;
+}
+
+</script>
+
+{% endif %}
diff --git a/xos/core/xoslib/methods/hpcview.py b/xos/core/xoslib/methods/hpcview.py
index f14b398..1118eda 100644
--- a/xos/core/xoslib/methods/hpcview.py
+++ b/xos/core/xoslib/methods/hpcview.py
@@ -84,7 +84,7 @@
if (network_name is None) or (network_name=="") or (network_name.lower()=="public"):
return instance.get_public_ip()
- for ns in instance.networkinstances.all():
+ for ns in instance.ports.all():
if (ns.ip) and (ns.network.name==network_name):
return ns.ip
diff --git a/xos/core/xoslib/static/js/xoslib/xos-backbone.js b/xos/core/xoslib/static/js/xoslib/xos-backbone.js
index a6c9465..dfc6c38 100644
--- a/xos/core/xoslib/static/js/xoslib/xos-backbone.js
+++ b/xos/core/xoslib/static/js/xoslib/xos-backbone.js
@@ -591,7 +591,7 @@
modelName: "port",
foreignFields: {"network": "networks", "instance": "instances"},
listFields: ["backend_status", "id", "network", "instance", "ip", "port_id"],
- detailFields: ["backend_status", "backend_register", "network", "instance", "ip", "port_id"],
+ detailFields: ["backend_status", "backend_register", "network", "instance", "ip", "mac", "port_id"],
});
define_model(this, {urlRoot: SERVICE_API,
diff --git a/xos/core/xoslib/static/js/xoslib/xos-defaults.js b/xos/core/xoslib/static/js/xoslib/xos-defaults.js
index 58f9258..4c38f3a 100644
--- a/xos/core/xoslib/static/js/xoslib/xos-defaults.js
+++ b/xos/core/xoslib/static/js/xoslib/xos-defaults.js
@@ -19,21 +19,21 @@
this.flavor = {"updated": null, "policed": null, "created": null, "default": false, "description": null, "enacted": null, "lazy_blocked": false, "backend_register": "{}", "deleted": false, "flavor": "", "backend_status": "0 - Provisioning in progress", "order": 0, "write_protect": false, "no_sync": false, "name": ""};
this.image = {"updated": null, "policed": null, "created": null, "deleted": false, "container_format": "", "disk_format": "", "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "path": null, "enacted": null, "backend_status": "0 - Provisioning in progress", "no_sync": false, "name": ""};
this.imageDeployments = {"updated": null, "policed": null, "created": null, "deleted": false, "image": null, "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "deployment": null, "backend_status": "0 - Provisioning in progress", "no_sync": false, "enacted": null};
+ this.instance = {"policed": null, "creator": null, "ip": null, "image": null, "backend_register": "{}", "flavor": 3, "backend_status": "0 - Provisioning in progress", "instance_id": null, "slice": null, "no_sync": false, "node": null, "userData": null, "updated": null, "deleted": false, "lazy_blocked": false, "deployment": null, "enacted": null, "instance_uuid": null, "numberCores": 0, "name": "", "created": null, "write_protect": false, "instance_name": null};
this.invoice = {"updated": null, "policed": null, "created": null, "deleted": false, "account": null, "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "date": null, "backend_status": "0 - Provisioning in progress", "no_sync": false, "enacted": null};
this.network = {"permit_all_slices": false, "policed": null, "labels": null, "backend_register": "{}", "owner": null, "backend_status": "0 - Provisioning in progress", "subnet": "", "subnet_id": null, "controller_parameters": null, "no_sync": false, "router_id": null, "updated": null, "controller_url": null, "template": null, "deleted": false, "lazy_blocked": false, "guaranteed_bandwidth": 0, "enacted": null, "autoconnect": true, "name": "", "created": null, "network_id": null, "write_protect": false, "topology_parameters": null, "ports": null};
this.networkParameter = {"updated": null, "policed": null, "created": null, "deleted": false, "value": "", "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "object_id": null, "content_type": null, "backend_status": "0 - Provisioning in progress", "parameter": null, "no_sync": false, "enacted": null};
this.networkParameterType = {"updated": null, "backend_status": "0 - Provisioning in progress", "description": "", "created": null, "deleted": false, "name": "", "backend_register": "{}", "write_protect": false, "enacted": null, "lazy_blocked": false, "no_sync": false, "policed": null};
this.networkSlice = {"updated": null, "slice": null, "policed": null, "created": null, "deleted": false, "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "enacted": null, "backend_status": "0 - Provisioning in progress", "no_sync": false, "network": null};
- this.networkInstance = {"updated": null, "policed": null, "created": null, "deleted": false, "ip": null, "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "no_sync": false, "enacted": null, "backend_status": "0 - Provisioning in progress", "port_id": null, "network": null, "instance": null};
this.networkTemplate = {"updated": null, "shared_network_name": null, "name": "", "created": null, "deleted": false, "description": null, "enacted": null, "visibility": "private", "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "no_sync": false, "topology_kind": "bigswitch", "guaranteed_bandwidth": 0, "translation": "none", "backend_status": "0 - Provisioning in progress", "shared_network_id": null, "controller_kind": null, "policed": null};
this.node = {"updated": null, "policed": null, "created": null, "deleted": false, "site": null, "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "no_sync": false, "enacted": null, "backend_status": "0 - Provisioning in progress", "site_deployment": null, "name": ""};
- this.payment = {"updated": null, "policed": null, "created": null, "deleted": false, "account": null, "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "amount": 0.0, "date": "2015-08-28T18:02:48.736Z", "backend_status": "0 - Provisioning in progress", "no_sync": false, "enacted": null};
- this.port = {"updated": null, "policed": null, "created": null, "deleted": false, "ip": null, "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "no_sync": false, "enacted": null, "backend_status": "0 - Provisioning in progress", "port_id": null, "network": null, "instance": null};
+ this.payment = {"updated": null, "policed": null, "created": null, "deleted": false, "account": null, "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "amount": 0.0, "date": "2015-09-14T22:58:03.982Z", "backend_status": "0 - Provisioning in progress", "no_sync": false, "enacted": null};
+ this.port = {"updated": null, "policed": null, "created": null, "deleted": false, "ip": null, "lazy_blocked": false, "backend_register": "{}", "instance": null, "mac": null, "enacted": null, "backend_status": "0 - Provisioning in progress", "port_id": null, "write_protect": false, "no_sync": false, "network": null};
this.program = {"status": null, "updated": null, "policed": null, "created": null, "deleted": false, "description": null, "messages": null, "kind": "", "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "command": null, "no_sync": false, "owner": null, "output": null, "enacted": null, "backend_status": "0 - Provisioning in progress", "contents": null, "name": ""};
this.project = {"updated": null, "policed": null, "created": null, "deleted": false, "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "enacted": null, "backend_status": "0 - Provisioning in progress", "no_sync": false, "name": ""};
this.provider = {"updated": null, "policed": null, "created": null, "deleted": false, "service_specific_attribute": null, "kind": "Provider", "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "service_specific_id": null, "enacted": null, "backend_status": "0 - Provisioning in progress", "no_sync": false, "name": null};
this.reservation = {"updated": null, "slice": null, "policed": null, "created": null, "deleted": false, "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "startTime": null, "duration": 1, "backend_status": "0 - Provisioning in progress", "no_sync": false, "enacted": null};
- this.reservedResource = {"updated": null, "backend_status": "0 - Provisioning in progress", "resource": null, "policed": null, "created": null, "deleted": false, "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "reservationSet": null, "enacted": null, "instance": null, "no_sync": false, "quantity": 1};
+ this.reservedResource = {"updated": null, "resource": null, "policed": null, "created": null, "deleted": false, "lazy_blocked": false, "backend_register": "{}", "instance": null, "reservationSet": null, "enacted": null, "backend_status": "0 - Provisioning in progress", "write_protect": false, "no_sync": false, "quantity": 1};
this.role = {"updated": null, "description": "", "created": null, "deleted": false, "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "role": null, "no_sync": false, "content_type": null, "enacted": null, "backend_status": "0 - Provisioning in progress", "role_type": "", "policed": null};
this.router = {"updated": null, "policed": null, "created": null, "deleted": false, "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "owner": null, "enacted": null, "backend_status": "0 - Provisioning in progress", "no_sync": false, "name": ""};
this.service = {"public_key": null, "updated": null, "policed": null, "created": null, "deleted": false, "view_url": null, "description": null, "service_specific_attribute": null, "enabled": true, "kind": "generic", "published": true, "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "versionNumber": "", "service_specific_id": null, "enacted": null, "backend_status": "0 - Provisioning in progress", "icon_url": null, "no_sync": false, "name": ""};
@@ -46,20 +46,20 @@
this.siteDeployment = {"updated": null, "policed": null, "availability_zone": null, "deleted": false, "created": null, "site": null, "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "controller": null, "deployment": null, "backend_status": "0 - Provisioning in progress", "no_sync": false, "enacted": null};
this.sitePrivilege = {"updated": null, "policed": null, "created": null, "deleted": false, "site": null, "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "role": null, "user": null, "backend_status": "0 - Provisioning in progress", "no_sync": false, "enacted": null};
this.siteRole = {"updated": null, "policed": null, "created": null, "deleted": false, "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "role": "", "backend_status": "0 - Provisioning in progress", "no_sync": false, "enacted": null};
- this.slice = {"policed": null, "creator": null, "site": null, "backend_register": "{}", "backend_status": "0 - Provisioning in progress", "network": "Private Only", "service": null, "no_sync": false, "default_flavor": null, "updated": null, "description": "", "deleted": false, "slice_url": "", "serviceClass": 1, "lazy_blocked": false, "omf_friendly": false, "mount_data_sets": "GenBank", "max_instances": 10, "enacted": null, "name": "", "created": null, "write_protect": false, "enabled": true, "default_image": null};
+ this.slice = {"policed": null, "creator": null, "site": null, "max_instances": 10, "backend_register": "{}", "backend_status": "0 - Provisioning in progress", "network": "Private Only", "service": null, "no_sync": false, "default_flavor": null, "updated": null, "description": "", "deleted": false, "slice_url": "", "serviceClass": 1, "lazy_blocked": false, "omf_friendly": false, "mount_data_sets": "GenBank", "enacted": null, "name": "", "created": null, "write_protect": false, "enabled": true, "default_image": null};
this.sliceCredential = {"updated": null, "slice": null, "policed": null, "created": null, "deleted": false, "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "key_id": "", "enacted": null, "enc_value": "", "backend_status": "0 - Provisioning in progress", "no_sync": false, "name": ""};
this.slicePrivilege = {"updated": null, "slice": null, "policed": null, "created": null, "deleted": false, "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "role": null, "user": null, "backend_status": "0 - Provisioning in progress", "no_sync": false, "enacted": null};
this.sliceRole = {"updated": null, "policed": null, "created": null, "deleted": false, "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "role": "", "backend_status": "0 - Provisioning in progress", "no_sync": false, "enacted": null};
this.sliceTag = {"updated": null, "slice": null, "policed": null, "created": null, "deleted": false, "value": "", "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "enacted": null, "backend_status": "0 - Provisioning in progress", "no_sync": false, "name": ""};
- this.instance = {"policed": null, "creator": null, "ip": null, "image": null, "backend_register": "{}", "flavor": 3, "backend_status": "0 - Provisioning in progress", "instance_id": null, "slice": null, "no_sync": false, "node": null, "userData": null, "updated": null, "deleted": false, "lazy_blocked": false, "deployment": null, "enacted": null, "instance_uuid": null, "numberCores": 0, "name": "", "created": null, "write_protect": false, "instance_name": null};
this.subscriber = {"updated": null, "policed": null, "created": null, "deleted": false, "service_specific_attribute": null, "kind": "Subscriber", "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "service_specific_id": null, "enacted": null, "backend_status": "0 - Provisioning in progress", "no_sync": false, "name": null};
this.tag = {"updated": null, "name": "", "service": null, "created": null, "deleted": false, "value": "", "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "object_id": null, "content_type": null, "enacted": null, "backend_status": "0 - Provisioning in progress", "no_sync": false, "policed": null};
this.tenant = {"subscriber_service": null, "connect_method": "na", "updated": null, "backend_status": "0 - Provisioning in progress", "policed": null, "created": null, "deleted": false, "service_specific_attribute": null, "kind": "generic", "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "enacted": null, "service_specific_id": null, "subscriber_tenant": null, "subscriber_root": null, "subscriber_user": null, "no_sync": false, "provider_service": null};
this.tenantRoot = {"updated": null, "policed": null, "created": null, "deleted": false, "service_specific_attribute": null, "kind": "generic", "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "service_specific_id": null, "enacted": null, "backend_status": "0 - Provisioning in progress", "no_sync": false, "name": null};
this.tenantRootPrivilege = {"updated": null, "policed": null, "created": null, "deleted": false, "tenant_root": null, "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "role": null, "user": null, "backend_status": "0 - Provisioning in progress", "no_sync": false, "enacted": null};
this.tenantRootRole = {"updated": null, "policed": null, "created": null, "deleted": false, "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "role": "", "backend_status": "0 - Provisioning in progress", "no_sync": false, "enacted": null};
+ this.tenantWithContainer = {"subscriber_service": null, "connect_method": "na", "updated": null, "backend_status": "0 - Provisioning in progress", "policed": null, "created": null, "deleted": false, "service_specific_attribute": null, "kind": "generic", "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "enacted": null, "service_specific_id": null, "subscriber_tenant": null, "subscriber_root": null, "subscriber_user": null, "no_sync": false, "provider_service": null};
this.usableObject = {"updated": null, "policed": null, "created": null, "deleted": false, "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "enacted": null, "backend_status": "0 - Provisioning in progress", "no_sync": false, "name": ""};
- this.user = {"policed": null, "site": null, "is_appuser": false, "is_staff": true, "timezone": "America/New_York", "backend_status": "Provisioning in progress", "is_registering": false, "last_login": "2015-08-28T18:02:48.780Z", "email": "", "username": "Something", "updated": null, "login_page": null, "firstname": "", "user_url": null, "deleted": false, "lastname": "", "is_active": true, "phone": null, "is_admin": false, "password": "", "enacted": null, "public_key": null, "is_readonly": false, "created": null, "write_protect": false};
+ this.user = {"policed": null, "site": null, "is_appuser": false, "is_staff": true, "timezone": "America/New_York", "backend_status": "Provisioning in progress", "is_registering": false, "last_login": "2015-09-14T22:58:04.005Z", "email": "", "username": "Something", "updated": null, "login_page": null, "firstname": "", "user_url": null, "deleted": false, "lastname": "", "is_active": true, "phone": null, "is_admin": false, "password": "", "enacted": null, "public_key": null, "is_readonly": false, "created": null, "write_protect": false};
this.userCredential = {"updated": null, "backend_status": "0 - Provisioning in progress", "policed": null, "created": null, "deleted": false, "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "user": null, "key_id": "", "enacted": null, "enc_value": "", "no_sync": false, "name": ""};
this.userDashboardView = {"updated": null, "policed": null, "created": null, "deleted": false, "dashboardView": null, "lazy_blocked": false, "backend_register": "{}", "write_protect": false, "user": null, "backend_status": "0 - Provisioning in progress", "order": 0, "no_sync": false, "enacted": null};
};
diff --git a/xos/core/xoslib/static/js/xoslib/xos-validators.js b/xos/core/xoslib/static/js/xoslib/xos-validators.js
index e4ecf51..bbba624 100644
--- a/xos/core/xoslib/static/js/xoslib/xos-validators.js
+++ b/xos/core/xoslib/static/js/xoslib/xos-validators.js
@@ -1,67 +1,66 @@
-
function xos_get_validators() {
- this.account = {"updated": [], "policed": [], "created": [], "deleted": [], "site": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.charge = {"updated": [], "slice": [], "policed": [], "created": [], "deleted": [], "amount": ["notBlank"], "object": ["notBlank"], "account": ["notBlank"], "kind": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "state": ["notBlank"], "coreHours": ["notBlank"], "invoice": [], "date": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.coarseTenant = {"subscriber_service": [], "connect_method": ["notBlank"], "updated": [], "policed": [], "created": [], "deleted": [], "service_specific_attribute": [], "kind": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "subscriber_user": [], "provider_service": ["notBlank"], "service_specific_id": [], "subscriber_tenant": [], "subscriber_root": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.controller = {"updated": [], "backend_type": ["notBlank"], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "domain": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "version": ["notBlank"], "auth_url": [], "admin_user": [], "deployment": ["notBlank"], "admin_password": [], "backend_status": ["notBlank"], "admin_tenant": [], "id": [], "no_sync": [], "enacted": []};
- this.controllerDashboardView = {"updated": [], "policed": [], "created": [], "deleted": [], "enabled": [], "dashboardView": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "controller": ["notBlank"], "url": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.controllerImages = {"updated": [], "glance_image_id": [], "policed": [], "created": [], "deleted": [], "image": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "controller": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.controllerNetwork = {"router_id": [], "subnet": [], "updated": [], "policed": [], "created": [], "deleted": [], "subnet_id": [], "net_id": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "controller": ["notBlank"], "network": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.controllerRole = {"updated": [], "policed": [], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "role": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.controllerSite = {"updated": [], "policed": [], "created": [], "deleted": [], "tenant_id": [], "site": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "controller": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.controllerSitePrivilege = {"updated": [], "policed": [], "created": [], "deleted": [], "role_id": [], "site_privilege": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "controller": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.controllerSlice = {"updated": [], "slice": ["notBlank"], "policed": [], "created": [], "deleted": [], "tenant_id": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "controller": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.controllerSlicePrivilege = {"updated": [], "slice_privilege": ["notBlank"], "policed": [], "created": [], "deleted": [], "role_id": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "controller": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.controllerUser = {"updated": [], "policed": [], "created": [], "deleted": [], "kuser_id": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "controller": ["notBlank"], "user": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.dashboardView = {"updated": [], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "enabled": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "url": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.deployment = {"accessControl": ["notBlank"], "updated": [], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.deploymentPrivilege = {"updated": [], "policed": [], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "role": ["notBlank"], "user": ["notBlank"], "deployment": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.deploymentRole = {"updated": [], "policed": [], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "role": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.flavor = {"default": [], "updated": [], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "description": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "flavor": ["notBlank"], "backend_status": ["notBlank"], "order": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.image = {"updated": [], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "container_format": ["notBlank"], "disk_format": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "path": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.imageDeployments = {"updated": [], "policed": [], "created": [], "deleted": [], "image": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "deployment": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.invoice = {"updated": [], "policed": [], "created": [], "deleted": [], "account": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "date": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.network = {"router_id": [], "policed": [], "labels": [], "backend_register": ["notBlank"], "owner": ["notBlank"], "backend_status": ["notBlank"], "id": [], "subnet": [], "subnet_id": [], "controller_parameters": [], "no_sync": [], "permit_all_slices": [], "updated": [], "controller_url": [], "template": ["notBlank"], "deleted": [], "lazy_blocked": [], "guaranteed_bandwidth": ["notBlank"], "enacted": [], "autoconnect": [], "name": ["notBlank"], "created": [], "write_protect": [], "network_id": [], "topology_parameters": [], "ports": []};
- this.networkParameter = {"updated": [], "policed": [], "created": [], "deleted": [], "value": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "object_id": ["notBlank"], "content_type": ["notBlank"], "backend_status": ["notBlank"], "parameter": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.networkParameterType = {"updated": [], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "description": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.networkSlice = {"updated": [], "slice": ["notBlank"], "policed": [], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "network": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.networkInstance = {"updated": [], "policed": [], "created": [], "deleted": [], "ip": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "instance": [], "network": ["notBlank"], "backend_status": ["notBlank"], "port_id": [], "id": [], "no_sync": [], "enacted": []};
- this.networkTemplate = {"shared_network_id": [], "updated": [], "shared_network_name": [], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "description": [], "visibility": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "controller_kind": [], "topology_kind": ["notBlank"], "guaranteed_bandwidth": ["notBlank"], "translation": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.node = {"updated": [], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "site": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "site_deployment": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.payment = {"updated": [], "policed": [], "created": [], "deleted": [], "account": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "amount": ["notBlank"], "date": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.port = {"updated": [], "policed": [], "created": [], "deleted": [], "ip": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "instance": [], "network": ["notBlank"], "backend_status": ["notBlank"], "port_id": [], "id": [], "no_sync": [], "enacted": []};
- this.program = {"status": [], "updated": [], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "description": [], "messages": [], "kind": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "command": [], "contents": [], "owner": ["notBlank"], "output": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.project = {"updated": [], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.provider = {"updated": [], "policed": [], "name": [], "created": [], "deleted": [], "service_specific_attribute": [], "kind": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "service_specific_id": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.reservation = {"updated": [], "slice": ["notBlank"], "policed": [], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "startTime": ["notBlank"], "duration": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.reservedResource = {"updated": [], "resource": ["notBlank"], "policed": [], "created": [], "deleted": [], "quantity": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "instance": ["notBlank"], "reservationSet": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.role = {"updated": [], "policed": [], "created": [], "deleted": [], "description": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "role": [], "role_type": ["notBlank"], "content_type": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.router = {"updated": [], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "owner": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.service = {"policed": [], "view_url": [], "backend_register": ["notBlank"], "backend_status": ["notBlank"], "id": [], "icon_url": [], "no_sync": [], "updated": [], "description": [], "deleted": [], "lazy_blocked": [], "versionNumber": ["notBlank"], "service_specific_id": [], "enacted": [], "public_key": [], "kind": ["notBlank"], "name": ["notBlank"], "created": [], "write_protect": [], "service_specific_attribute": [], "enabled": [], "published": []};
- this.serviceAttribute = {"updated": [], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "value": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "service": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.serviceClass = {"membershipFeeMonths": ["notBlank"], "updated": [], "membershipFee": ["notBlank"], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "description": ["notBlank"], "commitment": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "upgradeRequiresApproval": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.servicePrivilege = {"updated": [], "policed": [], "service": ["notBlank"], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "role": ["notBlank"], "user": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.serviceResource = {"updated": [], "maxUnitsNode": ["notBlank"], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "serviceClass": ["notBlank"], "maxUnitsDeployment": ["notBlank"], "maxDuration": ["notBlank"], "bucketMaxSize": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "cost": ["notBlank"], "calendarReservable": [], "bucketInRate": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.site = {"policed": [], "backend_register": ["notBlank"], "id": [], "backend_status": ["notBlank"], "abbreviated_name": ["notBlank"], "site_url": ["url"], "location": ["notBlank"], "hosts_nodes": [], "no_sync": [], "updated": [], "deleted": [], "lazy_blocked": [], "latitude": [], "is_public": [], "enacted": [], "name": ["notBlank"], "created": [], "write_protect": [], "enabled": [], "longitude": [], "hosts_users": [], "login_base": ["notBlank"]};
- this.siteCredential = {"updated": [], "enc_value": ["notBlank"], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "site": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "key_id": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.siteDeployment = {"updated": [], "policed": [], "created": [], "deleted": [], "availability_zone": [], "site": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "controller": [], "deployment": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.sitePrivilege = {"updated": [], "policed": [], "created": [], "deleted": [], "site": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "role": ["notBlank"], "user": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.siteRole = {"updated": [], "policed": [], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "role": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.slice = {"policed": [], "creator": [], "site": ["notBlank"], "backend_register": ["notBlank"], "backend_status": ["notBlank"], "id": [], "network": [], "service": [], "no_sync": [], "default_flavor": [], "updated": [], "description": [], "deleted": [], "slice_url": ["url"], "serviceClass": ["notBlank"], "lazy_blocked": [], "omf_friendly": [], "mount_data_sets": [], "max_instances": ["notBlank"], "enacted": [], "name": ["notBlank"], "created": [], "write_protect": [], "enabled": [], "default_image": []};
- this.sliceCredential = {"updated": [], "slice": ["notBlank"], "enc_value": ["notBlank"], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "key_id": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.slicePrivilege = {"updated": [], "slice": ["notBlank"], "policed": [], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "role": ["notBlank"], "user": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.sliceRole = {"updated": [], "policed": [], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "role": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.sliceTag = {"updated": [], "slice": ["notBlank"], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "value": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.instance = {"policed": [], "creator": [], "ip": [], "image": ["notBlank"], "backend_register": ["notBlank"], "flavor": ["notBlank"], "backend_status": ["notBlank"], "id": [], "instance_name": [], "slice": ["notBlank"], "no_sync": [], "node": ["notBlank"], "userData": [], "updated": [], "deleted": [], "lazy_blocked": [], "deployment": ["notBlank"], "enacted": [], "instance_uuid": [], "numberCores": ["notBlank"], "name": ["notBlank"], "created": [], "write_protect": [], "instance_id": []};
- this.subscriber = {"updated": [], "policed": [], "name": [], "created": [], "deleted": [], "service_specific_attribute": [], "kind": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "service_specific_id": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.tag = {"updated": [], "policed": [], "service": ["notBlank"], "created": [], "deleted": [], "name": ["notBlank"], "value": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "object_id": ["notBlank"], "content_type": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.tenant = {"subscriber_service": [], "connect_method": ["notBlank"], "updated": [], "policed": [], "created": [], "deleted": [], "service_specific_attribute": [], "kind": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "subscriber_user": [], "provider_service": ["notBlank"], "service_specific_id": [], "subscriber_tenant": [], "subscriber_root": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.tenantRoot = {"updated": [], "policed": [], "name": [], "created": [], "deleted": [], "service_specific_attribute": [], "kind": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "service_specific_id": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.tenantRootPrivilege = {"updated": [], "policed": [], "created": [], "deleted": [], "tenant_root": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "role": ["notBlank"], "user": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.tenantRootRole = {"updated": [], "policed": [], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "role": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.usableObject = {"updated": [], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.user = {"policed": ["notBlank"], "site": ["notBlank"], "is_appuser": [], "is_staff": [], "timezone": ["notBlank"], "backend_status": ["notBlank"], "id": [], "is_registering": [], "last_login": ["notBlank"], "email": ["notBlank"], "username": ["notBlank"], "updated": [], "login_page": [], "firstname": ["notBlank"], "user_url": ["url"], "deleted": [], "lastname": ["notBlank"], "is_active": [], "phone": [], "is_admin": [], "password": ["notBlank"], "enacted": ["notBlank"], "public_key": [], "is_readonly": [], "created": [], "write_protect": []};
- this.userCredential = {"updated": [], "enc_value": ["notBlank"], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "user": ["notBlank"], "key_id": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
- this.userDashboardView = {"updated": [], "policed": [], "created": [], "deleted": [], "dashboardView": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "user": ["notBlank"], "backend_status": ["notBlank"], "order": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.account = {"updated": [], "policed": [], "created": [], "deleted": [], "site": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.charge = {"updated": [], "slice": [], "policed": [], "created": [], "deleted": [], "amount": ["notBlank"], "object": ["notBlank"], "account": ["notBlank"], "kind": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "state": ["notBlank"], "coreHours": ["notBlank"], "invoice": [], "date": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.coarseTenant = {"subscriber_service": [], "connect_method": ["notBlank"], "updated": [], "policed": [], "created": [], "deleted": [], "service_specific_attribute": [], "kind": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "subscriber_user": [], "provider_service": ["notBlank"], "service_specific_id": [], "subscriber_tenant": [], "subscriber_root": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.controller = {"updated": [], "backend_type": ["notBlank"], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "domain": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "version": ["notBlank"], "auth_url": [], "admin_user": [], "deployment": ["notBlank"], "admin_password": [], "backend_status": ["notBlank"], "admin_tenant": [], "id": [], "no_sync": [], "enacted": []};
+ this.controllerDashboardView = {"updated": [], "policed": [], "created": [], "deleted": [], "enabled": [], "dashboardView": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "controller": ["notBlank"], "url": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.controllerImages = {"updated": [], "glance_image_id": [], "policed": [], "created": [], "deleted": [], "image": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "controller": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.controllerNetwork = {"router_id": [], "subnet": [], "updated": [], "policed": [], "created": [], "deleted": [], "subnet_id": [], "net_id": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "controller": ["notBlank"], "network": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.controllerRole = {"updated": [], "policed": [], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "role": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.controllerSite = {"updated": [], "policed": [], "created": [], "deleted": [], "tenant_id": [], "site": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "controller": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.controllerSitePrivilege = {"updated": [], "policed": [], "created": [], "deleted": [], "role_id": [], "site_privilege": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "controller": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.controllerSlice = {"updated": [], "slice": ["notBlank"], "policed": [], "created": [], "deleted": [], "tenant_id": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "controller": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.controllerSlicePrivilege = {"updated": [], "slice_privilege": ["notBlank"], "policed": [], "created": [], "deleted": [], "role_id": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "controller": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.controllerUser = {"updated": [], "policed": [], "created": [], "deleted": [], "kuser_id": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "controller": ["notBlank"], "user": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.dashboardView = {"updated": [], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "enabled": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "url": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.deployment = {"accessControl": ["notBlank"], "updated": [], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.deploymentPrivilege = {"updated": [], "policed": [], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "role": ["notBlank"], "user": ["notBlank"], "deployment": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.deploymentRole = {"updated": [], "policed": [], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "role": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.flavor = {"default": [], "updated": [], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "description": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "flavor": ["notBlank"], "backend_status": ["notBlank"], "order": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.image = {"updated": [], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "container_format": ["notBlank"], "disk_format": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "path": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.imageDeployments = {"updated": [], "policed": [], "created": [], "deleted": [], "image": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "deployment": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.instance = {"policed": [], "creator": [], "ip": [], "image": ["notBlank"], "backend_register": ["notBlank"], "flavor": ["notBlank"], "backend_status": ["notBlank"], "id": [], "instance_name": [], "slice": ["notBlank"], "no_sync": [], "node": ["notBlank"], "userData": [], "updated": [], "deleted": [], "lazy_blocked": [], "deployment": ["notBlank"], "enacted": [], "instance_uuid": [], "numberCores": ["notBlank"], "name": ["notBlank"], "created": [], "write_protect": [], "instance_id": []};
+ this.invoice = {"updated": [], "policed": [], "created": [], "deleted": [], "account": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "date": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.network = {"router_id": [], "policed": [], "labels": [], "backend_register": ["notBlank"], "owner": ["notBlank"], "backend_status": ["notBlank"], "id": [], "subnet": [], "subnet_id": [], "controller_parameters": [], "no_sync": [], "permit_all_slices": [], "updated": [], "controller_url": [], "template": ["notBlank"], "deleted": [], "lazy_blocked": [], "guaranteed_bandwidth": ["notBlank"], "enacted": [], "autoconnect": [], "name": ["notBlank"], "created": [], "write_protect": [], "network_id": [], "topology_parameters": [], "ports": []};
+ this.networkParameter = {"updated": [], "policed": [], "created": [], "deleted": [], "value": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "object_id": ["notBlank"], "content_type": ["notBlank"], "backend_status": ["notBlank"], "parameter": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.networkParameterType = {"updated": [], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "description": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.networkSlice = {"updated": [], "slice": ["notBlank"], "policed": [], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "network": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.networkTemplate = {"shared_network_id": [], "updated": [], "shared_network_name": [], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "description": [], "visibility": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "controller_kind": [], "topology_kind": ["notBlank"], "guaranteed_bandwidth": ["notBlank"], "translation": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.node = {"updated": [], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "site": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "site_deployment": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.payment = {"updated": [], "policed": [], "created": [], "deleted": [], "account": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "amount": ["notBlank"], "date": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.port = {"instance": [], "updated": [], "policed": [], "created": [], "deleted": [], "ip": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "mac": [], "network": ["notBlank"], "backend_status": ["notBlank"], "port_id": [], "id": [], "no_sync": [], "enacted": []};
+ this.program = {"status": [], "updated": [], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "description": [], "messages": [], "kind": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "command": [], "contents": [], "owner": ["notBlank"], "output": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.project = {"updated": [], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.provider = {"updated": [], "policed": [], "name": [], "created": [], "deleted": [], "service_specific_attribute": [], "kind": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "service_specific_id": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.reservation = {"updated": [], "slice": ["notBlank"], "policed": [], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "startTime": ["notBlank"], "duration": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.reservedResource = {"instance": ["notBlank"], "updated": [], "resource": ["notBlank"], "policed": [], "created": [], "deleted": [], "quantity": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "reservationSet": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.role = {"updated": [], "policed": [], "created": [], "deleted": [], "description": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "role": [], "role_type": ["notBlank"], "content_type": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.router = {"updated": [], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "owner": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.service = {"policed": [], "view_url": [], "backend_register": ["notBlank"], "backend_status": ["notBlank"], "id": [], "icon_url": [], "no_sync": [], "updated": [], "description": [], "deleted": [], "lazy_blocked": [], "versionNumber": ["notBlank"], "service_specific_id": [], "enacted": [], "public_key": [], "kind": ["notBlank"], "name": ["notBlank"], "created": [], "write_protect": [], "service_specific_attribute": [], "enabled": [], "published": []};
+ this.serviceAttribute = {"updated": [], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "value": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "service": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.serviceClass = {"membershipFeeMonths": ["notBlank"], "updated": [], "membershipFee": ["notBlank"], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "description": ["notBlank"], "commitment": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "upgradeRequiresApproval": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.servicePrivilege = {"updated": [], "policed": [], "service": ["notBlank"], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "role": ["notBlank"], "user": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.serviceResource = {"updated": [], "maxUnitsNode": ["notBlank"], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "serviceClass": ["notBlank"], "maxUnitsDeployment": ["notBlank"], "maxDuration": ["notBlank"], "bucketMaxSize": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "cost": ["notBlank"], "calendarReservable": [], "bucketInRate": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.site = {"policed": [], "backend_register": ["notBlank"], "id": [], "backend_status": ["notBlank"], "abbreviated_name": ["notBlank"], "site_url": ["url"], "location": ["notBlank"], "hosts_nodes": [], "no_sync": [], "updated": [], "deleted": [], "lazy_blocked": [], "latitude": [], "is_public": [], "enacted": [], "name": ["notBlank"], "created": [], "write_protect": [], "enabled": [], "longitude": [], "hosts_users": [], "login_base": ["notBlank"]};
+ this.siteCredential = {"updated": [], "enc_value": ["notBlank"], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "site": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "key_id": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.siteDeployment = {"updated": [], "policed": [], "created": [], "deleted": [], "availability_zone": [], "site": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "controller": [], "deployment": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.sitePrivilege = {"updated": [], "policed": [], "created": [], "deleted": [], "site": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "role": ["notBlank"], "user": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.siteRole = {"updated": [], "policed": [], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "role": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.slice = {"policed": [], "creator": [], "site": ["notBlank"], "max_instances": ["notBlank"], "backend_register": ["notBlank"], "backend_status": ["notBlank"], "id": [], "network": [], "service": [], "no_sync": [], "default_flavor": [], "updated": [], "description": [], "deleted": [], "slice_url": ["url"], "serviceClass": ["notBlank"], "lazy_blocked": [], "omf_friendly": [], "mount_data_sets": [], "enacted": [], "name": ["notBlank"], "created": [], "write_protect": [], "enabled": [], "default_image": []};
+ this.sliceCredential = {"updated": [], "slice": ["notBlank"], "enc_value": ["notBlank"], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "key_id": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.slicePrivilege = {"updated": [], "slice": ["notBlank"], "policed": [], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "role": ["notBlank"], "user": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.sliceRole = {"updated": [], "policed": [], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "role": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.sliceTag = {"updated": [], "slice": ["notBlank"], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "value": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.subscriber = {"updated": [], "policed": [], "name": [], "created": [], "deleted": [], "service_specific_attribute": [], "kind": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "service_specific_id": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.tag = {"updated": [], "policed": [], "service": ["notBlank"], "created": [], "deleted": [], "name": ["notBlank"], "value": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "object_id": ["notBlank"], "content_type": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.tenant = {"subscriber_service": [], "connect_method": ["notBlank"], "updated": [], "policed": [], "created": [], "deleted": [], "service_specific_attribute": [], "kind": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "subscriber_user": [], "provider_service": ["notBlank"], "service_specific_id": [], "subscriber_tenant": [], "subscriber_root": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.tenantRoot = {"updated": [], "policed": [], "name": [], "created": [], "deleted": [], "service_specific_attribute": [], "kind": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "service_specific_id": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.tenantRootPrivilege = {"updated": [], "policed": [], "created": [], "deleted": [], "tenant_root": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "role": ["notBlank"], "user": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.tenantRootRole = {"updated": [], "policed": [], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "role": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.tenantWithContainer = {"subscriber_service": [], "connect_method": ["notBlank"], "updated": [], "policed": [], "created": [], "deleted": [], "service_specific_attribute": [], "kind": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "subscriber_user": [], "provider_service": ["notBlank"], "service_specific_id": [], "subscriber_tenant": [], "subscriber_root": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.usableObject = {"updated": [], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.user = {"policed": ["notBlank"], "site": ["notBlank"], "is_appuser": [], "is_staff": [], "timezone": ["notBlank"], "backend_status": ["notBlank"], "id": [], "is_registering": [], "last_login": ["notBlank"], "email": ["notBlank"], "username": ["notBlank"], "updated": [], "login_page": [], "firstname": ["notBlank"], "user_url": ["url"], "deleted": [], "lastname": ["notBlank"], "is_active": [], "phone": [], "is_admin": [], "password": ["notBlank"], "enacted": ["notBlank"], "public_key": [], "is_readonly": [], "created": [], "write_protect": []};
+ this.userCredential = {"updated": [], "enc_value": ["notBlank"], "policed": [], "name": ["notBlank"], "created": [], "deleted": [], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "user": ["notBlank"], "key_id": ["notBlank"], "backend_status": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
+ this.userDashboardView = {"updated": [], "policed": [], "created": [], "deleted": [], "dashboardView": ["notBlank"], "lazy_blocked": [], "backend_register": ["notBlank"], "write_protect": [], "user": ["notBlank"], "backend_status": ["notBlank"], "order": ["notBlank"], "id": [], "no_sync": [], "enacted": []};
};
xosvalidators = new xos_get_validators();
diff --git a/xos/dmdot b/xos/dmdot
old mode 100644
new mode 100755
index d1b11c1..8570c4d
--- a/xos/dmdot
+++ b/xos/dmdot
@@ -12,7 +12,7 @@
from django.db.models.fields.related import ForeignKey
# defaults
-app = "core"
+apps = ["core", "hpc", "cord", "requestrouter"]
output = "-json"
# syntax: dmdot [-json | -dot] [app_name]
@@ -24,35 +24,36 @@
else:
app = arg
-app = app + ".models"
-#models_module = imp.load_source(app, ".")
-models_module = __import__(app)
-for part in app.split(".")[1:]:
- if hasattr(models_module, "PlCoreBase"):
- break
- models_module = getattr(models_module,part)
-
-PlCoreBase = getattr(models_module,"PlCoreBase")
-
-synonyms = {
- 'user':'creator'
-}
-
model_classes = []
class_names = []
lower_class_names = {}
-for classname in dir(models_module):
- c = getattr(models_module, classname, None)
- if type(c)==type(PlCoreBase):
- model_classes.append(c)
- class_names.append(c.__name__)
- lower_class_names[c.__name__.lower()] = c
- try:
- synonym = synonyms[c.__name__.lower()]
- lower_class_names[synonym] = c
- except:
- pass
-
+synonyms = {
+ 'user':'creator'
+}
+
+for app in apps:
+ app = app + ".models"
+ #models_module = imp.load_source(app, ".")
+ models_module = __import__(app)
+ for part in app.split(".")[1:]:
+ if hasattr(models_module, "PlCoreBase"):
+ break
+ models_module = getattr(models_module,part)
+
+ PlCoreBase = getattr(models_module,"PlCoreBase")
+
+ for classname in dir(models_module):
+ c = getattr(models_module, classname, None)
+ if type(c)==type(PlCoreBase):
+ model_classes.append(c)
+ class_names.append(c.__name__)
+ lower_class_names[c.__name__.lower()] = c
+ try:
+ synonym = synonyms[c.__name__.lower()]
+ lower_class_names[synonym] = c
+ except:
+ pass
+
# django doesn't use the correct case in field.name.title() for objects that
# have CamelCased class names. So, compare everything in lower case.
@@ -63,20 +64,32 @@
fields = c._meta.fields
for f in fields:
- if type(f)==ForeignKey and f.name.lower() in lower_class_names:
+ if type(f)==ForeignKey and f.name.lower().split('_') in lower_class_names:
linked_class = lower_class_names[f.name.lower()]
- print '\t"%s"->"%s";'%(c.__name__,linked_class.__name__)
+ if ('backref' in f.name):
+ print '\t"%s"->"%s";'%(linked_class.__name__,c.__name__)
+ else:
+ print '\t"%s"->"%s";'%(c.__name__,linked_class.__name__)
print "}\n";
elif (output=='-json'):
d = {}
for c in model_classes:
fields = c._meta.fields
-
+
for f in fields:
- if type(f)==ForeignKey and f.name.lower() in lower_class_names:
- linked_class = lower_class_names[f.name.lower()]
+ field_type = f.name.lower().split('_')[0]
+ if type(f)==ForeignKey and field_type in lower_class_names:
+ linked_class = lower_class_names[field_type]
+ if ('backref' in f.name.lower()):
+ a = linked_class.__name__
+ b = c.__name__
+ else:
+ b = linked_class.__name__
+ a = c.__name__
+
try:
- d[c.__name__].append(linked_class.__name__)
+ if (b not in d[a]):
+ d[a].append(b)
except KeyError:
d[c.__name__]=[linked_class.__name__]
#d['ControllerNetwork'].append('SliceDeployments')
diff --git a/xos/helloworld/__init__.py b/xos/helloworld/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/xos/helloworld/__init__.py
diff --git a/xos/helloworld/models.py b/xos/helloworld/models.py
new file mode 100644
index 0000000..37f6751
--- /dev/null
+++ b/xos/helloworld/models.py
@@ -0,0 +1,18 @@
+from django.db import models
+from core.models import User, Service, SingletonModel, PlCoreBase, Instance
+from core.models.plcorebase import StrippedCharField
+import os
+from django.db import models
+from django.forms.models import model_to_dict
+from django.db.models import Q
+
+
+# Create your models here.
+
+class Hello(PlCoreBase):
+ name = models.CharField(max_length=254,help_text="Salutation e.g. Hello or Bonjour")
+ sliver_backref = models.ForeignKey(Instance)
+
+class World(PlCoreBase):
+ name = models.CharField(max_length=254,help_text="Name of planet")
+ hello = models.ForeignKey(Hello)
diff --git a/xos/model-deps b/xos/model-deps
index 0218517..ea32eb9 100644
--- a/xos/model-deps
+++ b/xos/model-deps
@@ -10,8 +10,7 @@
"Deployment"
],
"ControllerImages": [
- "Image",
- "Controller"
+ "Image"
],
"ReservedResource": [
"Instance"
@@ -72,10 +71,7 @@
"Instance": [
"Image",
"User",
- "Slice",
- "Deployment",
- "Node",
- "Flavor"
+ "Slice"
],
"Payment": [
"Account"
diff --git a/xos/model_policy.py b/xos/model_policy.py
index ce59a32..ced785e 100644
--- a/xos/model_policy.py
+++ b/xos/model_policy.py
@@ -97,9 +97,14 @@
pass
def run_policy():
- from core.models import Instance,Slice,Controller,Network,User,SlicePrivilege,Site,SitePrivilege,Image,ControllerSlice,ControllerUser,ControllerSite
while (True):
start = time.time()
+ run_policy_once()
+ if (time.time()-start<1):
+ time.sleep(1)
+
+def run_policy_once():
+ from core.models import Instance,Slice,Controller,Network,User,SlicePrivilege,Site,SitePrivilege,Image,ControllerSlice,ControllerUser,ControllerSite
models = [Instance,Slice, Controller, Network, User, SlicePrivilege, Site, SitePrivilege, Image, ControllerSlice, ControllerSite, ControllerUser]
objects = []
deleted_objects = []
@@ -132,6 +137,3 @@
except:
# this shouldn't happen, but in case it does, catch it...
logger.log_exc("exception in reset_queries")
-
- if (time.time()-start<1):
- time.sleep(1)
diff --git a/xos/observers/base/SyncInstanceUsingAnsible.py b/xos/observers/base/SyncInstanceUsingAnsible.py
new file mode 100644
index 0000000..9455780
--- /dev/null
+++ b/xos/observers/base/SyncInstanceUsingAnsible.py
@@ -0,0 +1,95 @@
+import hashlib
+import os
+import socket
+import sys
+import base64
+import time
+from django.db.models import F, Q
+from xos.config import Config
+from observer.syncstep import SyncStep
+from observer.ansible import run_template_ssh
+from core.models import Service, Slice
+from util.logger import Logger, logging
+
+logger = Logger(level=logging.INFO)
+
+class SyncInstanceUsingAnsible(SyncStep):
+ # All of the following should be defined for classes derived from this
+ # base class. Examples below use VCPETenant.
+
+ # provides=[VCPETenant]
+ # observes=VCPETenant
+ # requested_interval=0
+ # template_name = "sync_vcpetenant.yaml"
+ # service_key_name = "/opt/xos/observers/vcpe/vcpe_private_key"
+
+ def __init__(self, **args):
+ SyncStep.__init__(self, **args)
+
+ def defer_sync(self, o, reason):
+ logger.info("defer object %s due to %s" % (str(o), reason))
+ raise Exception("defer object %s due to %s" % (str(o), reason))
+
+ def get_extra_attributes(self, o):
+ # This is a place to include extra attributes that aren't part of the
+ # object itself.
+
+ return {}
+
+ def get_instance(self, o):
+ # We need to know what instance is associated with the object. Let's
+ # assume 'o' has a field called 'instance'. If the field is called
+ # something else, or if custom logic is needed, then override this
+ # method.
+
+ return o.instance
+
+ def run_playbook(self, o, fields):
+ tStart = time.time()
+ run_template_ssh(self.template_name, fields)
+ logger.info("playbook execution time %d" % int(time.time()-tStart))
+
+ def pre_sync_hook(self, o, fields):
+ pass
+
+ def post_sync_hook(self, o, fields):
+ pass
+
+ def sync_fields(self, o, fields):
+ self.run_playbook(o, fields)
+
+ def sync_record(self, o):
+ logger.info("sync'ing object %s" % str(o))
+
+ instance = self.get_instance(o)
+ if not instance:
+ self.defer_sync(o, "waiting on instance")
+ return
+
+ if not os.path.exists(self.service_key_name):
+ raise Exception("Service key %s does not exist" % self.service_key_name)
+
+ service_key = file(self.service_key_name).read()
+
+ fields = { "instance_name": instance.name,
+ "hostname": instance.node.name,
+ "instance_id": instance.instance_id,
+ "private_key": service_key,
+ "ansible_tag": "vcpe_tenant_" + str(o.id)
+ }
+
+ # If 'o' defines a 'sync_attributes' list, then we'll copy those
+ # attributes into the Ansible recipe's field list automatically.
+ if hasattr(o, "sync_attributes"):
+ for attribute_name in o.sync_attributes:
+ fields[attribute_name] = getattr(o, attribute_name)
+
+ fields.update(self.get_extra_attributes(o))
+
+ self.sync_fields(o, fields)
+
+ o.save()
+
+ def delete_record(self, m):
+ pass
+
diff --git a/xos/observers/hello_world/helloworld-observer.py b/xos/observers/hello_world/helloworld-observer.py
new file mode 100755
index 0000000..d6a71ff
--- /dev/null
+++ b/xos/observers/hello_world/helloworld-observer.py
@@ -0,0 +1,11 @@
+#!/usr/bin/env python
+
+# This imports and runs ../../xos-observer.py
+
+import importlib
+import os
+import sys
+observer_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),"../..")
+sys.path.append(observer_path)
+mod = importlib.import_module("xos-observer")
+mod.main()
diff --git a/xos/observers/hello_world/helloworld_config b/xos/observers/hello_world/helloworld_config
new file mode 100644
index 0000000..97248ae
--- /dev/null
+++ b/xos/observers/hello_world/helloworld_config
@@ -0,0 +1,46 @@
+[plc]
+name=plc
+deployment=plc
+
+[db]
+name=xos
+user=postgres
+password=password
+host=localhost
+port=5432
+
+[api]
+host=localhost
+port=8000
+ssl_key=None
+ssl_cert=None
+ca_ssl_cert=None
+ratelimit_enabled=0
+omf_enabled=0
+mail_support_address=support@localhost
+nova_enabled=True
+logfile=/var/log/xos.log
+
+[nova]
+admin_user=admin@domain.com
+admin_password=admin
+admin_tenant=admin
+url=http://localhost:5000/v2.0/
+default_image=None
+default_flavor=m1.small
+default_security_group=default
+ca_ssl_cert=/etc/ssl/certs/ca-certificates.crt
+
+[observer]
+pretend=False
+backoff_disabled=False
+images_directory=/opt/xos/images
+dependency_graph=/opt/xos/model-deps
+logfile=/var/log/xos_backend.log
+steps_dir=/opt/xos/observers/hello_world/steps
+
+[gui]
+disable_minidashboard=True
+#branding_name=CORD
+#branding_css=/static/cord.css
+#branding_icon=/static/onos-logo.png
diff --git a/xos/observers/hello_world/model-deps b/xos/observers/hello_world/model-deps
new file mode 100644
index 0000000..63188f0
--- /dev/null
+++ b/xos/observers/hello_world/model-deps
@@ -0,0 +1,19 @@
+{
+ "OriginServer": [
+ "ContentProvider"
+ ],
+ "ContentProvider": [
+ "ServiceProvider"
+ ],
+ "CDNPrefix": [
+ "ContentProvider"
+ ],
+ "AccessMap": [
+ "ContentProvider"
+ ],
+ "SiteMap": [
+ "ContentProvider",
+ "ServiceProvider",
+ "CDNPrefix"
+ ]
+}
diff --git a/xos/observers/hello_world/nohup.out b/xos/observers/hello_world/nohup.out
new file mode 100644
index 0000000..74072c6
--- /dev/null
+++ b/xos/observers/hello_world/nohup.out
@@ -0,0 +1 @@
+python: can't open file 'helloworld-observer.py': [Errno 2] No such file or directory
diff --git a/xos/observers/hello_world/run.sh b/xos/observers/hello_world/run.sh
new file mode 100755
index 0000000..f77d751
--- /dev/null
+++ b/xos/observers/hello_world/run.sh
@@ -0,0 +1,6 @@
+#if [[ ! -e ./hpc-backend.py ]]; then
+# ln -s ../xos-observer.py hpc-backend.py
+#fi
+
+export XOS_DIR=/opt/xos
+python hpc-observer.py -C $XOS_DIR/observers/hpc/hpc_observer_config
diff --git a/xos/observers/hello_world/start.sh b/xos/observers/hello_world/start.sh
new file mode 100755
index 0000000..89240cd
--- /dev/null
+++ b/xos/observers/hello_world/start.sh
@@ -0,0 +1,4 @@
+export XOS_DIR=/opt/xos
+
+echo $XOS_DIR/observers/helloworld/helloworld_config
+python helloworld-observer.py -C $XOS_DIR/observers/helloworld/helloworld_config
diff --git a/xos/observers/hello_world/steps/sync_hello.py b/xos/observers/hello_world/steps/sync_hello.py
new file mode 100644
index 0000000..f59ec5c
--- /dev/null
+++ b/xos/observers/hello_world/steps/sync_hello.py
@@ -0,0 +1,24 @@
+import os
+import sys
+import base64
+from django.db.models import F, Q
+from xos.config import Config
+from observer.syncstep import SyncStep
+from helloworld.models import Hello,World
+from util.logger import Logger, logging
+
+parentdir = os.path.join(os.path.dirname(__file__),"..")
+sys.path.insert(0,parentdir)
+
+logger = Logger(level=logging.INFO)
+
+class SyncHello(SyncStep):
+ provides=[Hello]
+ observes=Hello
+ requested_interval=0
+
+ def sync_record(self, record):
+ open('/tmp/hello-synchronizer','w').write(record.name)
+
+ def delete_record(self, m):
+ return
diff --git a/xos/observers/hello_world/steps/sync_world.py b/xos/observers/hello_world/steps/sync_world.py
new file mode 100644
index 0000000..01e285f
--- /dev/null
+++ b/xos/observers/hello_world/steps/sync_world.py
@@ -0,0 +1,25 @@
+import os
+import sys
+import base64
+from django.db.models import F, Q
+from xos.config import Config
+from observer.syncstep import SyncStep
+from helloworld.models import Hello,World
+from util.logger import Logger, logging
+
+# hpclibrary will be in steps/..
+parentdir = os.path.join(os.path.dirname(__file__),"..")
+sys.path.insert(0,parentdir)
+
+logger = Logger(level=logging.INFO)
+
+class SyncWorld(SyncStep):
+ provides=[World]
+ observes=World
+ requested_interval=0
+
+ def sync_record(self, record):
+ open('/tmp/hello-synchronizer','w').write(record.name)
+
+ def delete_record(self, m):
+ return
diff --git a/xos/observers/hello_world/stop.sh b/xos/observers/hello_world/stop.sh
new file mode 100755
index 0000000..a0b4a8e
--- /dev/null
+++ b/xos/observers/hello_world/stop.sh
@@ -0,0 +1 @@
+pkill -9 -f hpc-observer.py
diff --git a/xos/openstack_observer/ansible.py b/xos/openstack_observer/ansible.py
old mode 100755
new mode 100644
index fad7610..ee110c9
--- a/xos/openstack_observer/ansible.py
+++ b/xos/openstack_observer/ansible.py
@@ -10,6 +10,7 @@
import traceback
import subprocess
from xos.config import Config, XOS_DIR
+from util.logger import observer_logger
try:
step_dir = Config().observer_steps_dir
@@ -24,7 +25,8 @@
def parse_output(msg):
lines = msg.splitlines()
results = []
- print msg
+
+ observer_logger.info(msg)
for l in lines:
magic_str = 'ok: [127.0.0.1] => '
@@ -45,6 +47,7 @@
def parse_unreachable(msg):
total_unreachable=0
+ total_failed=0
for l in msg.splitlines():
x = re.findall('ok=([0-9]+).*changed=([0-9]+).*unreachable=([0-9]+).*failed=([0-9]+)', l)
if x:
@@ -55,8 +58,9 @@
failed=int(failed)
total_unreachable += unreachable
- return total_unreachable
-
+ total_failed += failed
+ return {'unreachable':total_unreachable,'failed':total_failed}
+
def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
return ''.join(random.choice(chars) for _ in range(size))
@@ -118,7 +122,12 @@
if (expected_num is not None) and (len(ok_results) != expected_num):
raise ValueError('Unexpected num %s!=%d' % (str(expected_num), len(ok_results)) )
- total_unreachable = parse_unreachable(msg)
+ parsed = parse_unreachable(msg)
+ total_unreachable = parsed['unreachable']
+ failed = parsed['failed']
+ if (failed):
+ raise ValueError('Ansible playbook failed.')
+
if (total_unreachable > 0):
raise ValueError("Unreachable results in ansible recipe")
except ValueError,e:
@@ -181,7 +190,7 @@
print "ANSIBLE_CONFIG=%s" % config_pathname
print "ANSIBLE_HOSTS=%s" % hosts_pathname
- return run_template(name, opts, path, expected_num, ansible_config = config_pathname, ansible_hosts = hosts_pathname, run_ansible_script="/opt/xos/observer/run_ansible_verbose")
+ return run_template(name, opts, path, ansible_config = config_pathname, ansible_hosts = hosts_pathname, run_ansible_script="/opt/xos/observer/run_ansible_verbose")
diff --git a/xos/openstack_observer/event_loop.py b/xos/openstack_observer/event_loop.py
index fc07e7d..17d5c7a 100644
--- a/xos/openstack_observer/event_loop.py
+++ b/xos/openstack_observer/event_loop.py
@@ -68,7 +68,7 @@
class XOSObserver:
sync_steps = []
-
+
def __init__(self):
# The Condition object that gets signalled by Feefie events
self.step_lookup = {}
@@ -83,6 +83,10 @@
else:
self.driver = NoOpDriver()
+ def consolePrint(self, what):
+ if getattr(Config(), "observer_console_print", True):
+ print what
+
def wait_for_event(self, timeout):
self.event_cond.acquire()
self.event_cond.wait(timeout)
@@ -115,7 +119,6 @@
if inspect.isclass(c) and (issubclass(c, SyncStep) or issubclass(c,OpenStackSyncStep)) and hasattr(c,"provides") and (c not in self.sync_steps):
self.sync_steps.append(c)
logger.info('loaded sync steps: %s' % ",".join([x.__name__ for x in self.sync_steps]))
- # print 'loaded sync steps: %s' % ",".join([x.__name__ for x in self.sync_steps])
def load_sync_steps(self):
dep_path = Config().observer_dependency_graph
@@ -179,6 +182,8 @@
except:
step_graph[source]=[dest]
except KeyError:
+ if (not provides_dict.has_key(m)):
+ step_graph[source]='#%s'%m
pass
except KeyError:
@@ -190,14 +195,10 @@
self.deletion_dependency_graph = invert_graph(step_graph)
pp = pprint.PrettyPrinter(indent=4)
- pp.pprint(step_graph)
+ logger.info(pp.pformat(step_graph))
self.ordered_steps = toposort(self.dependency_graph, map(lambda s:s.__name__,self.sync_steps))
- #self.ordered_steps = ['SyncRoles', 'SyncControllerSites', 'SyncControllerSitePrivileges','SyncImages', 'SyncControllerImages','SyncControllerUsers','SyncControllerUserSitePrivileges','SyncControllerSlices', 'SyncControllerSlicePrivileges', 'SyncControllerUserSlicePrivileges', 'SyncControllerNetworks','SyncInstances']
- #self.ordered_steps = ['SyncControllerSites','SyncRoles','SyncControllerUsers','SyncControllerSlices','SyncControllerNetworks']
- #self.ordered_steps = ['SyncControllerNetworks']
- #self.ordered_steps = ['SyncInstances','SyncNetworkInstances']
- print "Order of steps=",self.ordered_steps
+ logger.info("Order of steps=%s" % self.ordered_steps)
self.load_run_times()
@@ -244,7 +245,17 @@
for e in self.ordered_steps:
self.last_deletion_run_times[e]=0
-
+ def lookup_step(self,s):
+ if ('#' in s):
+ objname = s[1:]
+ so = SyncObject()
+ so.provides=[globals()[objname]]
+ so.observes=globals()[objname]
+ step = so
+ else:
+ step = self.step_lookup[s]
+ return step
+
def save_run_times(self):
run_times = json.dumps(self.last_run_times)
open('/tmp/%sobserver_run_times'%self.observer_name,'w').write(run_times)
@@ -264,7 +275,7 @@
def sync(self, S, deletion):
try:
- step = self.step_lookup[S]
+ step = self.lookup_step(S)
start_time=time.time()
logger.info("Starting to work on step %s, deletion=%s" % (step.__name__, str(deletion)))
@@ -307,7 +318,7 @@
go = True
if (not go):
- print bcolors.FAIL + "Step %r skipped on %r" % (step,failed_dep) + bcolors.ENDC
+ self.consolePrint(bcolors.FAIL + "Step %r skipped on %r" % (step,failed_dep) + bcolors.ENDC)
# SMBAKER: sync_step was not defined here, so I changed
# this from 'sync_step' to 'step'. Verify.
self.failed_steps.append(step)
@@ -350,7 +361,7 @@
logger.info('Executing step %s, deletion=%s' % (sync_step.__name__, deletion))
- print bcolors.OKBLUE + "Executing step %s" % sync_step.__name__ + bcolors.ENDC
+ self.consolePrint(bcolors.OKBLUE + "Executing step %s" % sync_step.__name__ + bcolors.ENDC)
failed_objects = sync_step(failed=list(self.failed_step_objects), deletion=deletion)
self.check_duration(sync_step, duration)
@@ -359,11 +370,11 @@
self.failed_step_objects.update(failed_objects)
logger.info("Step %r succeeded" % sync_step.__name__)
- print bcolors.OKGREEN + "Step %r succeeded" % sync_step.__name__ + bcolors.ENDC
+ self.consolePrint(bcolors.OKGREEN + "Step %r succeeded" % sync_step.__name__ + bcolors.ENDC)
my_status = STEP_STATUS_OK
self.update_run_time(sync_step,deletion)
except Exception,e:
- print bcolors.FAIL + "Model step %r failed" % (sync_step.__name__) + bcolors.ENDC
+ self.consolePrint(bcolors.FAIL + "Model step %r failed" % (sync_step.__name__) + bcolors.ENDC)
logger.error('Model step %r failed. This seems like a misconfiguration or bug: %r. This error will not be relayed to the user!' % (sync_step.__name__, e))
logger.log_exc(e)
self.failed_steps.append(S)
@@ -398,72 +409,74 @@
return
while True:
- try:
- loop_start = time.time()
- error_map_file = getattr(Config(), "error_map_path", XOS_DIR + "/error_map.txt")
- self.error_mapper = ErrorMapper(error_map_file)
+ logger.info('Waiting for event')
+ self.wait_for_event(timeout=5)
+ logger.info('Observer woke up')
- logger.info('Waiting for event')
- tBeforeWait = time.time()
- self.wait_for_event(timeout=5)
- logger.info('Observer woke up')
+ self.run_once()
- # Two passes. One for sync, the other for deletion.
- for deletion in [False,True]:
- # Set of individual objects within steps that failed
- self.failed_step_objects = set()
+ def run_once(self):
+ try:
+ loop_start = time.time()
+ error_map_file = getattr(Config(), "error_map_path", XOS_DIR + "/error_map.txt")
+ self.error_mapper = ErrorMapper(error_map_file)
- # Set up conditions and step status
- # This is needed for steps to run in parallel
- # while obeying dependencies.
+ # Two passes. One for sync, the other for deletion.
+ for deletion in [False,True]:
+ # Set of individual objects within steps that failed
+ self.failed_step_objects = set()
- providers = set()
- dependency_graph = self.dependency_graph if not deletion else self.deletion_dependency_graph
+ # Set up conditions and step status
+ # This is needed for steps to run in parallel
+ # while obeying dependencies.
- for v in dependency_graph.values():
- if (v):
- providers.update(v)
+ providers = set()
+ dependency_graph = self.dependency_graph if not deletion else self.deletion_dependency_graph
- self.step_conditions = {}
- self.step_status = {}
+ for v in dependency_graph.values():
+ if (v):
+ providers.update(v)
- for p in list(providers):
- self.step_conditions[p] = threading.Condition()
+ self.step_conditions = {}
+ self.step_status = {}
- self.step_status[p] = STEP_STATUS_WORKING
+ for p in list(providers):
+ self.step_conditions[p] = threading.Condition()
- self.failed_steps = []
+ self.step_status[p] = STEP_STATUS_WORKING
- threads = []
- logger.info('Deletion=%r...'%deletion)
- schedule = self.ordered_steps if not deletion else reversed(self.ordered_steps)
+ self.failed_steps = []
- for S in schedule:
- thread = threading.Thread(target=self.sync, args=(S, deletion))
+ threads = []
+ logger.info('Deletion=%r...'%deletion)
+ schedule = self.ordered_steps if not deletion else reversed(self.ordered_steps)
- logger.info('Deletion=%r...'%deletion)
- threads.append(thread)
+ for S in schedule:
+ thread = threading.Thread(target=self.sync, args=(S, deletion))
- # Start threads
- for t in threads:
- t.start()
+ logger.info('Deletion=%r...'%deletion)
+ threads.append(thread)
- # another spot to clean up debug state
- try:
- reset_queries()
- except:
- # this shouldn't happen, but in case it does, catch it...
- logger.log_exc("exception in reset_queries")
+ # Start threads
+ for t in threads:
+ t.start()
- # Wait for all threads to finish before continuing with the run loop
- for t in threads:
- t.join()
+ # another spot to clean up debug state
+ try:
+ reset_queries()
+ except:
+ # this shouldn't happen, but in case it does, catch it...
+ logger.log_exc("exception in reset_queries")
- self.save_run_times()
+ # Wait for all threads to finish before continuing with the run loop
+ for t in threads:
+ t.join()
- loop_end = time.time()
- open('/tmp/%sobserver_last_run'%self.observer_name,'w').write(json.dumps({'last_run': loop_end, 'last_duration':loop_end - loop_start}))
- except Exception, e:
- logger.error('Core error. This seems like a misconfiguration or bug: %r. This error will not be relayed to the user!' % e)
- logger.log_exc("Exception in observer run loop")
- traceback.print_exc()
+ self.save_run_times()
+
+ loop_end = time.time()
+ open('/tmp/%sobserver_last_run'%self.observer_name,'w').write(json.dumps({'last_run': loop_end, 'last_duration':loop_end - loop_start}))
+ except Exception, e:
+ logger.error('Core error. This seems like a misconfiguration or bug: %r. This error will not be relayed to the user!' % e)
+ logger.log_exc("Exception in observer run loop")
+ traceback.print_exc()
diff --git a/xos/openstack_observer/steps/purge_disabled_users.py b/xos/openstack_observer/steps/purge_disabled_users.py
index 9e30708..b5168e3 100644
--- a/xos/openstack_observer/steps/purge_disabled_users.py
+++ b/xos/openstack_observer/steps/purge_disabled_users.py
@@ -20,5 +20,6 @@
# disabled users that haven't been updated in over a week
one_week_ago = datetime.datetime.now() - datetime.timedelta(days=7)
return User.objects.filter(is_active=False, updated__gt=one_week_ago)
+
def sync_record(self, user):
user.delete()
diff --git a/xos/openstack_observer/steps/sync_controller_images.py b/xos/openstack_observer/steps/sync_controller_images.py
index 527ad49..153558e 100644
--- a/xos/openstack_observer/steps/sync_controller_images.py
+++ b/xos/openstack_observer/steps/sync_controller_images.py
@@ -15,6 +15,7 @@
provides=[ControllerImages]
observes = ControllerImages
requested_interval=0
+ playbook='sync_controller_images.yaml'
def fetch_pending(self, deleted):
if (deleted):
@@ -23,13 +24,7 @@
# now we return all images that need to be enacted
return ControllerImages.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
- def sync_record(self, controller_image):
- logger.info("Working on image %s on controller %s" % (controller_image.image.name, controller_image.controller))
-
- controller_register = json.loads(controller_image.controller.backend_register)
- if (controller_register.get('disabled',False)):
- raise InnocuousException('Controller %s is disabled'%controller_image.controller.name)
-
+ def map_inputs(self, controller_image):
image_fields = {'endpoint':controller_image.controller.auth_url,
'endpoint_v3': controller_image.controller.auth_url_v3,
'admin_user':controller_image.controller.admin_user,
@@ -40,9 +35,9 @@
'ansible_tag': '%s@%s'%(controller_image.image.name,controller_image.controller.name), # name of ansible playbook
}
+ return image_fields
- res = run_template('sync_controller_images.yaml', image_fields, path='controller_images', expected_num=1)
-
+ def map_outputs(self, controller_image):
image_id = res[0]['id']
controller_image.glance_image_id = image_id
controller_image.backend_status = '1 - OK'
diff --git a/xos/openstack_observer/steps/sync_controller_networks.py b/xos/openstack_observer/steps/sync_controller_networks.py
index 9983d88..0ce3a96 100644
--- a/xos/openstack_observer/steps/sync_controller_networks.py
+++ b/xos/openstack_observer/steps/sync_controller_networks.py
@@ -20,6 +20,7 @@
requested_interval = 0
provides=[Network]
observes=ControllerNetwork
+ playbook='sync_controller_networks.yaml'
def alloc_subnet(self, uuid):
# 16 bits only
@@ -37,6 +38,7 @@
network_name = controller_network.network.name
subnet_name = '%s-%d'%(network_name,controller_network.pk)
cidr = self.alloc_subnet(controller_network.pk)
+ self.cidr=cidr
slice = controller_network.network.owner
network_fields = {'endpoint':controller_network.controller.auth_url,
@@ -51,46 +53,37 @@
'cidr':cidr,
'delete':False
}
+ return network_fields
- res = run_template('sync_controller_networks.yaml', network_fields, path = 'controller_networks',expected_num=2)
-
+ def map_sync_outputs(self, controller_network,res):
network_id = res[0]['id']
subnet_id = res[1]['id']
controller_network.net_id = network_id
- controller_network.subnet = cidr
+ controller_network.subnet = self.cidr
controller_network.subnet_id = subnet_id
controller_network.backend_status = '1 - OK'
controller_network.save()
- def sync_record(self, controller_network):
+ def map_sync_inputs(self, controller_network):
if (controller_network.network.template.name!='Private'):
logger.info("skipping network controller %s because it is not private" % controller_network)
# We only sync private networks
return
- logger.info("sync'ing network controller %s for network %s slice %s controller %s" % (controller_network, controller_network.network, str(controller_network.network.owner), controller_network.controller))
-
- controller_register = json.loads(controller_network.controller.backend_register)
- if (controller_register.get('disabled',False)):
- raise InnocuousException('Controller %s is disabled'%controller_network.controller.name)
-
if not controller_network.controller.admin_user:
logger.info("controller %r has no admin_user, skipping" % controller_network.controller)
return
if controller_network.network.owner and controller_network.network.owner.creator:
- self.save_controller_network(controller_network)
- logger.info("saved network controller: %s" % (controller_network))
+ return self.save_controller_network(controller_network)
+ else:
+ raise Exception('Could not save network controller %s'%controller_network)
- def delete_record(self, controller_network):
+ def map_delete_inputs(self, controller_network):
if (controller_network.network.template.name!='Private'):
# We only sync private networks
return
- controller_register = json.loads(controller_network.controller.backend_register)
- if (controller_register.get('disabled',False)):
- raise InnocuousException('Controller %s is disabled'%controller_network.controller.name)
-
try:
slice = controller_network.network.owner # XXX: FIXME!!
except:
@@ -110,7 +103,7 @@
'delete':True
}
- res = run_template('sync_controller_networks.yaml', network_fields, path = 'controller_networks',expected_num=1)
+ return network_fields
"""
driver = OpenStackDriver().client_driver(caller=controller_network.network.owner.creator,
diff --git a/xos/openstack_observer/steps/sync_controller_site_privileges.py b/xos/openstack_observer/steps/sync_controller_site_privileges.py
index f66607b..d257536 100644
--- a/xos/openstack_observer/steps/sync_controller_site_privileges.py
+++ b/xos/openstack_observer/steps/sync_controller_site_privileges.py
@@ -16,27 +16,14 @@
provides=[SitePrivilege]
requested_interval=0
observes=ControllerSitePrivilege
+ playbook='sync_controller_users.yaml'
- def fetch_pending(self, deleted):
-
- if (deleted):
- return ControllerSitePrivilege.deleted_objects.all()
- else:
- return ControllerSitePrivilege.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
-
- def sync_record(self, controller_site_privilege):
- logger.info("sync'ing controler_site_privilege %s at controller %s" % (controller_site_privilege, controller_site_privilege.controller))
-
+ def map_sync_inputs(self, controller_site_privilege):
controller_register = json.loads(controller_site_privilege.controller.backend_register)
- if (controller_register.get('disabled',False)):
- raise InnocuousException('Controller %s is disabled'%controller_site_privilege.controller.name)
-
-
if not controller_site_privilege.controller.admin_user:
logger.info("controller %r has no admin_user, skipping" % controller_site_privilege.controller)
return
- template = os_template_env.get_template('sync_controller_users.yaml')
roles = [controller_site_privilege.site_privilege.role.role]
# setup user home site roles at controller
if not controller_site_privilege.site_privilege.user.site:
@@ -65,10 +52,9 @@
'roles':roles,
'tenant':controller_site_privilege.site_privilege.site.login_base}
- rendered = template.render(user_fields)
- expected_length = len(roles) + 1
- res = run_template('sync_controller_users.yaml', user_fields,path='controller_site_privileges', expected_num=expected_length)
+ return user_fields
+ def map_sync_outputs(self, controller_site_privilege, res):
# results is an array in which each element corresponds to an
# "ok" string received per operation. If we get as many oks as
# the number of operations we issued, that means a grand success.
diff --git a/xos/openstack_observer/steps/sync_controller_sites.py b/xos/openstack_observer/steps/sync_controller_sites.py
index ce64f2f..614d435 100644
--- a/xos/openstack_observer/steps/sync_controller_sites.py
+++ b/xos/openstack_observer/steps/sync_controller_sites.py
@@ -13,17 +13,13 @@
requested_interval=0
provides=[Site]
observes=ControllerSite
+ playbook = 'sync_controller_sites.yaml'
def fetch_pending(self, deleted=False):
- pending = super(OpenStackSyncStep, self).fetch_pending(deleted)
- return pending.filter(controller__isnull=False)
+ lobjs = ControllerSite.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None),Q(lazy_blocked=False),Q(controller__isnull=False))
+ return lobjs
- def sync_record(self, controller_site):
- controller_register = json.loads(controller_site.controller.backend_register)
- if (controller_register.get('disabled',False)):
- raise InnocuousException('Controller %s is disabled'%controller_site.controller.name)
-
- template = os_template_env.get_template('sync_controller_sites.yaml')
+ def map_sync_inputs(self, controller_site):
tenant_fields = {'endpoint':controller_site.controller.auth_url,
'endpoint_v3': controller_site.controller.auth_url_v3,
'domain': controller_site.controller.domain,
@@ -33,10 +29,9 @@
'ansible_tag': '%s@%s'%(controller_site.site.login_base,controller_site.controller.name), # name of ansible playbook
'tenant': controller_site.site.login_base,
'tenant_description': controller_site.site.name}
+ return tenant_fields
- rendered = template.render(tenant_fields)
- res = run_template('sync_controller_sites.yaml', tenant_fields, path='controller_sites', expected_num=1)
-
+ def map_sync_outputs(self, controller_site, res):
controller_site.tenant_id = res[0]['id']
controller_site.backend_status = '1 - OK'
controller_site.save()
diff --git a/xos/openstack_observer/steps/sync_controller_slice_privileges.py b/xos/openstack_observer/steps/sync_controller_slice_privileges.py
index 744bb38..948ea57 100644
--- a/xos/openstack_observer/steps/sync_controller_slice_privileges.py
+++ b/xos/openstack_observer/steps/sync_controller_slice_privileges.py
@@ -16,21 +16,9 @@
provides=[SlicePrivilege]
requested_interval=0
observes=ControllerSlicePrivilege
+ playbook = 'sync_controller_users.yaml'
- def fetch_pending(self, deleted):
-
- if (deleted):
- return ControllerSlicePrivilege.deleted_objects.all()
- else:
- return ControllerSlicePrivilege.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
-
- def sync_record(self, controller_slice_privilege):
- logger.info("sync'ing controler_slice_privilege %s at controller %s" % (controller_slice_privilege, controller_slice_privilege.controller))
-
- controller_register = json.loads(controller_slice_privilege.controller.backend_register)
- if (controller_register.get('disabled',False)):
- raise InnocuousException('Controller %s is disabled'%controller_slice_privilege.controller.name)
-
+ def map_inputs(self, controller_slice_privilege):
if not controller_slice_privilege.controller.admin_user:
logger.info("controller %r has no admin_user, skipping" % controller_slice_privilege.controller)
return
@@ -63,17 +51,11 @@
'admin_tenant': controller_slice_privilege.controller.admin_tenant,
'roles':roles,
'tenant':controller_slice_privilege.slice_privilege.slice.name}
+ return user_fields
- rendered = template.render(user_fields)
- expected_length = len(roles) + 1
- res = run_template('sync_controller_users.yaml', user_fields, path='controller_slice_privileges', expected_num=expected_length)
-
- # results is an array in which each element corresponds to an
- # "ok" string received per operation. If we get as many oks as
- # the number of operations we issued, that means a grand success.
- # Otherwise, the number of oks tell us which operation failed.
- controller_slice_privilege.role_id = res[0]['id']
- controller_slice_privilege.save()
+ def map_sync_outputs(self, controller_slice_privilege, res):
+ controller_slice_privilege.role_id = res[0]['id']
+ controller_slice_privilege.save()
def delete_record(self, controller_slice_privilege):
controller_register = json.loads(controller_slice_privilege.controller.backend_register)
diff --git a/xos/openstack_observer/steps/sync_controller_slices.py b/xos/openstack_observer/steps/sync_controller_slices.py
index 5ab9603..9904aef 100644
--- a/xos/openstack_observer/steps/sync_controller_slices.py
+++ b/xos/openstack_observer/steps/sync_controller_slices.py
@@ -16,20 +16,11 @@
provides=[Slice]
requested_interval=0
observes=ControllerSlice
+ playbook='sync_controller_slices.yaml'
- def fetch_pending(self, deleted):
- if (deleted):
- return ControllerSlice.deleted_objects.all()
- else:
- return ControllerSlice.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
-
- def sync_record(self, controller_slice):
+ def map_sync_inputs(self, controller_slice):
logger.info("sync'ing slice controller %s" % controller_slice)
- controller_register = json.loads(controller_slice.controller.backend_register)
- if (controller_register.get('disabled',False)):
- raise InnocuousException('Controller %s is disabled'%controller_slice.controller.name)
-
if not controller_slice.controller.admin_user:
logger.info("controller %r has no admin_user, skipping" % controller_slice.controller)
return
@@ -56,8 +47,9 @@
'ansible_tag':'%s@%s'%(controller_slice.slice.name,controller_slice.controller.name),
'max_instances':max_instances}
- expected_num = len(roles)+1
- res = run_template('sync_controller_slices.yaml', tenant_fields, path='controller_slices', expected_num=expected_num)
+ return tenant_fields
+
+ def map_sync_outputs(self, controller_slice, res):
tenant_id = res[0]['id']
if (not controller_slice.tenant_id):
try:
@@ -72,11 +64,7 @@
controller_slice.save()
- def delete_record(self, controller_slice):
- controller_register = json.loads(controller_slice.controller.backend_register)
- if (controller_register.get('disabled',False)):
- raise InnocuousException('Controller %s is disabled'%controller_slice.controller.name)
-
+ def map_delete_inputs(self, controller_slice):
controller_users = ControllerUser.objects.filter(user=controller_slice.slice.creator,
controller=controller_slice.controller)
if not controller_users:
@@ -93,6 +81,4 @@
'name':controller_user.user.email,
'ansible_tag':'%s@%s'%(controller_slice.slice.name,controller_slice.controller.name),
'delete': True}
-
- expected_num = 1
- run_template('sync_controller_slices.yaml', tenant_fields, path='controller_slices', expected_num=expected_num)
+ return tenant_fields
diff --git a/xos/openstack_observer/steps/sync_controller_users.py b/xos/openstack_observer/steps/sync_controller_users.py
index 505ba87..4062453 100644
--- a/xos/openstack_observer/steps/sync_controller_users.py
+++ b/xos/openstack_observer/steps/sync_controller_users.py
@@ -16,27 +16,13 @@
provides=[User]
requested_interval=0
observes=ControllerUser
+ playbook='sync_controller_users.yaml'
- def fetch_pending(self, deleted):
-
- if (deleted):
- return ControllerUser.deleted_objects.all()
- else:
- return ControllerUser.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
-
- def sync_record(self, controller_user):
- logger.info("sync'ing user %s at controller %s" % (controller_user.user, controller_user.controller))
-
- controller_register = json.loads(controller_user.controller.backend_register)
- if (controller_register.get('disabled',False)):
- raise InnocuousException('Controller %s is disabled'%controller_user.controller.name)
-
+ def map_sync_inputs(self, controller_user):
if not controller_user.controller.admin_user:
logger.info("controller %r has no admin_user, skipping" % controller_user.controller)
return
- template = os_template_env.get_template('sync_controller_users.yaml')
-
# All users will have at least the 'user' role at their home site/tenant.
# We must also check if the user should have the admin role
roles = ['user']
@@ -70,21 +56,14 @@
'roles':roles,
'tenant':controller_user.user.site.login_base
}
+ return user_fields
- rendered = template.render(user_fields)
- expected_length = len(roles) + 1
-
- res = run_template('sync_controller_users.yaml', user_fields,path='controller_users', expected_num=expected_length)
-
- controller_user.kuser_id = res[0]['id']
- controller_user.backend_status = '1 - OK'
- controller_user.save()
+ def map_sync_outputs(self, controller_user, res):
+ controller_user.kuser_id = res[0]['id']
+ controller_user.backend_status = '1 - OK'
+ controller_user.save()
def delete_record(self, controller_user):
- controller_register = json.loads(controller_user.controller.backend_register)
- if (controller_register.get('disabled',False)):
- raise InnocuousException('Controller %s is disabled'%controller_user.controller.name)
-
if controller_user.kuser_id:
driver = self.driver.admin_driver(controller=controller_user.controller)
driver.delete_user(controller_user.kuser_id)
diff --git a/xos/openstack_observer/steps/sync_instances.py b/xos/openstack_observer/steps/sync_instances.py
index 402e9a0..7aa4bb7 100644
--- a/xos/openstack_observer/steps/sync_instances.py
+++ b/xos/openstack_observer/steps/sync_instances.py
@@ -20,6 +20,7 @@
provides=[Instance]
requested_interval=0
observes=Instance
+ playbook='sync_instances.yaml'
def get_userdata(self, instance, pubkeys):
userdata = '#cloud-config\n\nopencloud:\n slicename: "%s"\n hostname: "%s"\n restapi_hostname: "%s"\n restapi_port: "%s"\n' % (instance.slice.name, instance.node.name, RESTAPI_HOSTNAME, str(RESTAPI_PORT))
@@ -28,14 +29,9 @@
userdata += ' - %s\n' % key
return userdata
- def sync_record(self, instance):
- logger.info("sync'ing instance:%s slice:%s controller:%s " % (instance, instance.slice.name, instance.node.site_deployment.controller))
- controller_register = json.loads(instance.node.site_deployment.controller.backend_register)
-
- if (controller_register.get('disabled',False)):
- raise InnocuousException('Controller %s is disabled'%instance.node.site_deployment.controller.name)
-
- metadata_update = {}
+ def map_sync_inputs(self, instance):
+ inputs = {}
+ metadata_update = {}
if (instance.numberCores):
metadata_update["cpu_cores"] = str(instance.numberCores)
@@ -43,8 +39,7 @@
if tag.name.startswith("sysctl-"):
metadata_update[tag.name] = tag.value
- # public keys
- slice_memberships = SlicePrivilege.objects.filter(slice=instance.slice)
+ slice_memberships = SlicePrivilege.objects.filter(slice=instance.slice)
pubkeys = set([sm.user.public_key for sm in slice_memberships if sm.user.public_key])
if instance.creator.public_key:
pubkeys.add(instance.creator.public_key)
@@ -55,23 +50,8 @@
if instance.slice.service and instance.slice.service.public_key:
pubkeys.add(instance.slice.service.public_key)
- # Handle any ports that are already created and attached to the instance.
- # If we do have a port for a network, then add that network to an
- # exclude list so we won't try to auto-create ports on that network
- # when instantiating.
- ports = []
- exclude_networks = set()
- exclude_templates = set()
- for ns in instance.ports.all():
- if not ns.port_id:
- raise DeferredException("Port %s on instance %s has no id; Try again later" % (str(ns), str(instance)) )
- ports.append(ns.port_id)
- exclude_networks.add(ns.network)
- exclude_templates.add(ns.network.template)
-
nics = []
networks = [ns.network for ns in NetworkSlice.objects.filter(slice=instance.slice)]
- networks = [n for n in networks if (n not in exclude_networks)]
controller_networks = ControllerNetwork.objects.filter(network__in=networks,
controller=instance.node.site_deployment.controller)
@@ -79,14 +59,12 @@
if controller_network.network.template.visibility == 'private' and \
controller_network.network.template.translation == 'none':
if not controller_network.net_id:
- raise DeferredException("Private Network %s has no id; Try again later" % controller_network.network.name)
+ raise Exception("Private Network %s has no id; Try again later" % controller_network.network.name)
nics.append(controller_network.net_id)
- # Now include network templates, for those networks that use a
- # shared_network_name.
+ # now include network template
network_templates = [network.template.shared_network_name for network in networks \
if network.template.shared_network_name]
- network_templates = [nt for nt in network_templates if (nt not in exclude_templates)]
#driver = self.driver.client_driver(caller=instance.creator, tenant=instance.slice.name, controller=instance.controllerNetwork)
driver = self.driver.admin_driver(tenant='admin', controller=instance.node.site_deployment.controller)
@@ -95,9 +73,7 @@
if net['name'] in network_templates:
nics.append(net['id'])
- # If the slice isn't connected to anything, then at least put it on
- # the public network.
- if (not nics) and (not ports):
+ if (not nics):
for net in nets:
if net['name']=='public':
nics.append(net['id'])
@@ -116,7 +92,7 @@
image_name = image.name
logger.info("using image from glance: " + str(image_name))
- try:
+ try:
legacy = Config().observer_legacy
except:
legacy = False
@@ -128,13 +104,14 @@
availability_zone_filter = 'nova:%s'%host_filter
instance_name = '%s-%d'%(instance.slice.name,instance.id)
+ self.instance_name = instance_name
userData = self.get_userdata(instance, pubkeys)
if instance.userData:
userData = instance.userData
controller = instance.node.site_deployment.controller
- tenant_fields = {'endpoint':controller.auth_url,
+ fields = {'endpoint':controller.auth_url,
'endpoint_v3': controller.auth_url_v3,
'domain': controller.domain,
'admin_user': instance.creator.email,
@@ -148,15 +125,16 @@
'image_name':image_name,
'flavor_name':instance.flavor.name,
'nics':nics,
- 'ports':ports,
'meta':metadata_update,
'user_data':r'%s'%escape(userData)}
+ return fields
- res = run_template('sync_instances.yaml', tenant_fields,path='instances', expected_num=1)
- instance_id = res[0]['info']['OS-EXT-SRV-ATTR:instance_name']
+
+ def map_sync_outputs(self, instance, res):
+ instance_id = res[0]['info']['OS-EXT-SRV-ATTR:instance_name']
instance_uuid = res[0]['id']
- try:
+ try:
hostname = res[0]['info']['OS-EXT-SRV-ATTR:hypervisor_hostname']
ip = socket.gethostbyname(hostname)
instance.ip = ip
@@ -165,10 +143,11 @@
instance.instance_id = instance_id
instance.instance_uuid = instance_uuid
- instance.instance_name = instance_name
+ instance.instance_name = self.instance_name
instance.save()
-
- def delete_record(self, instance):
+
+
+ def map_delete_inputs(self, instance):
controller_register = json.loads(instance.node.site_deployment.controller.backend_register)
if (controller_register.get('disabled',False)):
@@ -176,7 +155,7 @@
instance_name = '%s-%d'%(instance.slice.name,instance.id)
controller = instance.node.site_deployment.controller
- tenant_fields = {'endpoint':controller.auth_url,
+ input = {'endpoint':controller.auth_url,
'admin_user': instance.creator.email,
'admin_password': instance.creator.remote_password,
'admin_tenant': instance.slice.name,
@@ -185,14 +164,4 @@
'name':instance_name,
'ansible_tag':instance_name,
'delete': True}
-
- try:
- res = run_template('sync_instances.yaml', tenant_fields,path='instances', expected_num=1)
- except Exception,e:
- print "Could not sync %s"%instance_name
- #import traceback
- #traceback.print_exc()
- raise e
-
- if (len(res)!=1):
- raise Exception('Could not delete instance %s'%instance.slice.name)
+ return input
diff --git a/xos/openstack_observer/steps/sync_object.py b/xos/openstack_observer/steps/sync_object.py
new file mode 100644
index 0000000..5e70464
--- /dev/null
+++ b/xos/openstack_observer/steps/sync_object.py
@@ -0,0 +1,20 @@
+import os
+import base64
+from collections import defaultdict
+from django.db.models import F, Q
+from xos.config import Config
+from observer.openstacksyncstep import OpenStackSyncStep
+from observer.syncstep import *
+from core.models import *
+from observer.ansible import *
+from openstack.driver import OpenStackDriver
+from util.logger import observer_logger as logger
+import json
+
+class SyncObject(OpenStackSyncStep):
+ provides=[] # Caller fills this in
+ requested_interval=0
+ observes=[] # Caller fills this in
+
+ def sync_record(self, r):
+ raise Exception('Waiting for Service dependency')
diff --git a/xos/openstack_observer/steps/sync_ports.py b/xos/openstack_observer/steps/sync_ports.py
index 15fd4a1..18e0d00 100644
--- a/xos/openstack_observer/steps/sync_ports.py
+++ b/xos/openstack_observer/steps/sync_ports.py
@@ -115,7 +115,7 @@
network = None
for candidate_network in networks:
if (candidate_network.owner == instance.slice):
- print "found network", candidate_network
+ logger.info("found network %s" % candidate_network)
network = candidate_network
if not network:
@@ -178,10 +178,11 @@
client = OpenStackClient(controller=controller, **auth) # cacert=self.config.nova_ca_ssl_cert,
driver = OpenStackDriver(client=client)
- port = driver.shell.quantum.create_port({"port": {"network_id": cn.net_id}})["port"]
- port.port_id = port["id"]
- if port["fixed_ips"]:
- port.ip = port["fixed_ips"][0]["ip_address"]
+ neutron_port = driver.shell.quantum.create_port({"port": {"network_id": cn.net_id}})["port"]
+ port.port_id = neutron_port["id"]
+ if neutron_port["fixed_ips"]:
+ port.ip = neutron_port["fixed_ips"][0]["ip_address"]
+ port.mac = neutron_port["mac_address"]
except:
logger.log_exc("failed to create neutron port for %s" % port)
continue
diff --git a/xos/openstack_observer/steps/sync_roles.py b/xos/openstack_observer/steps/sync_roles.py
index 42a36c6..c4bbe3f 100644
--- a/xos/openstack_observer/steps/sync_roles.py
+++ b/xos/openstack_observer/steps/sync_roles.py
@@ -11,27 +11,7 @@
class SyncRoles(OpenStackSyncStep):
provides=[Role]
requested_interval=0
- observes=Role
-
- def fetch_pending(self, deleted):
- # Deleting roles is not supported yet
- if (deleted):
- return []
-
- site_roles = SiteRole.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
- slice_roles = SliceRole.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
- controller_roles = ControllerRole.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
-
- roles = []
- for site_role in site_roles:
- roles.append(site_role)
- for slice_role in slice_roles:
- roles.append(slice_role)
- for controller_role in controller_roles:
- roles.append(controller_role)
-
- return roles
-
+ observes=[SiteRole,SliceRole,ControllerRole]
def sync_record(self, role):
if not role.enacted:
diff --git a/xos/openstack_observer/syncstep.py b/xos/openstack_observer/syncstep.py
index 791a89a..66225d0 100644
--- a/xos/openstack_observer/syncstep.py
+++ b/xos/openstack_observer/syncstep.py
@@ -7,6 +7,8 @@
from django.db.models import F, Q
from core.models import *
from django.db import reset_queries
+from observer.ansible import *
+
import json
import time
import pdb
@@ -73,11 +75,18 @@
# This is the most common implementation of fetch_pending
# Steps should override it if they have their own logic
# for figuring out what objects are outstanding.
- main_obj = self.observes
- if (not deletion):
- objs = main_obj.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None), Q(lazy_blocked=False), Q(no_sync=False))
- else:
- objs = main_obj.deleted_objects.all()
+
+ main_objs = self.observes
+ if (type(main_objs) is not list):
+ main_objs=[main_objs]
+
+ objs = []
+ for main_obj in main_objs:
+ if (not deletion):
+ lobjs = main_obj.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None),Q(lazy_blocked=False),Q(no_sync=False))
+ else:
+ lobjs = main_obj.deleted_objects.all()
+ objs.extend(lobjs)
return objs
#return Instance.objects.filter(ip=None)
@@ -107,8 +116,58 @@
obj.save(update_fields=['backend_status'])
raise FailedDependency("Failed dependency for %s:%s peer %s:%s failed %s:%s" % (obj.__class__.__name__, str(getattr(obj,"pk","no_pk")), peer_object.__class__.__name__, str(getattr(peer_object,"pk","no_pk")), failed.__class__.__name__, str(getattr(failed,"pk","no_pk"))))
+
+ def sync_record(self, o):
+ try:
+ controller = o.get_controller()
+ controller_register = json.loads(o.node.site_deployment.controller.backend_register)
+
+ if (controller_register.get('disabled',False)):
+ raise InnocuousException('Controller %s is disabled'%sliver.node.site_deployment.controller.name)
+ except AttributeError:
+ pass
+
+ tenant_fields = self.map_sync_inputs(o)
+ main_objs=self.observes
+ if (type(main_objs) is list):
+ main_objs=main_objs[0]
+
+ path = ''.join(main_objs.__name__).lower()
+ res = run_template(self.playbook,tenant_fields,path=path)
+
+ try:
+ self.map_sync_outputs(o,res)
+ except AttributeError:
+ pass
+
+ def delete_record(self, o):
+ try:
+ controller = o.get_controller()
+ controller_register = json.loads(o.node.site_deployment.controller.backend_register)
+
+ if (controller_register.get('disabled',False)):
+ raise InnocuousException('Controller %s is disabled'%sliver.node.site_deployment.controller.name)
+ except AttributeError:
+ pass
+
+ tenant_fields = self.map_delete_inputs(o)
+
+ main_objs=self.observes
+ if (type(main_objs) is list):
+ main_objs=main_objs[0]
+
+ path = ''.join(main_objs.__name__).lower()
+
+ tenant_fields['delete']=True
+ res = run_template(self.playbook,tenant_fields,path=path)
+ try:
+ self.map_delete_outputs(o,res)
+ except AttributeError:
+ pass
+
def call(self, failed=[], deletion=False):
pending = self.fetch_pending(deletion)
+
for o in pending:
# another spot to clean up debug state
try:
@@ -207,11 +266,5 @@
return failed
- def sync_record(self, o):
- return
-
- def delete_record(self, o):
- return
-
def __call__(self, **args):
return self.call(**args)
diff --git a/xos/tools/get_instance_ip.py b/xos/tools/get_instance_ip.py
index dd3c788..1783b25 100644
--- a/xos/tools/get_instance_ip.py
+++ b/xos/tools/get_instance_ip.py
@@ -71,7 +71,7 @@
instance_id = instances[-1]["id"]
- r = requests.get(NETWORKINSTANCES_API + "?instance=%s" % instance_id, auth=opencloud_auth)
+ r = requests.get(PORTS_API + "?instance=%s" % instance_id, auth=opencloud_auth)
ports = r.json()
ips = [x["ip"] for x in ports]
diff --git a/xos/tosca/custom_types/xos.m4 b/xos/tosca/custom_types/xos.m4
index 0a68c9d..629c378 100644
--- a/xos/tosca/custom_types/xos.m4
+++ b/xos/tosca/custom_types/xos.m4
@@ -139,6 +139,9 @@
derived_from: tosca.nodes.Root
properties:
xos_base_tenant_props
+ vlan_id:
+ type: string
+ required: false
tosca.nodes.User:
derived_from: tosca.nodes.Root
@@ -377,6 +380,12 @@
slice:
type: tosca.capabilities.xos.Slice
+ tosca.nodes.Node:
+ derived_from: tosca.nodes.Root
+ capability:
+ node:
+ type: tosca.capabilities.xos.Node
+
tosca.relationships.MemberOfSlice:
derived_from: tosca.relationships.Root
valid_target_types: [ tosca.capabilities.xos.Slice ]
@@ -389,6 +398,10 @@
derived_from: tosca.relationships.Root
valid_target_types: [ tosca.capabilities.xos.Site ]
+ tosca.relationships.MemberOfDeployment:
+ derived_from: tosca.relationships.Root
+ valid_target_types: [ tosca.capabilities.xos.Deployment ]
+
tosca.relationships.TenantOfService:
derived_from: tosca.relationships.Root
valid_target_types: [ tosca.capabilities.xos.Service ]
@@ -478,3 +491,7 @@
derived_from: tosca.capabilities.Root
description: An XOS Subscriber
+ tosca.capabilities.xos.Node:
+ derived_from: tosca.capabilities.Root
+ description: An XOS Node
+
diff --git a/xos/tosca/custom_types/xos.yaml b/xos/tosca/custom_types/xos.yaml
index c59842f..6611198 100644
--- a/xos/tosca/custom_types/xos.yaml
+++ b/xos/tosca/custom_types/xos.yaml
@@ -201,6 +201,9 @@
service_specific_id:
type: string
required: false
+ vlan_id:
+ type: string
+ required: false
tosca.nodes.User:
derived_from: tosca.nodes.Root
@@ -439,6 +442,12 @@
slice:
type: tosca.capabilities.xos.Slice
+ tosca.nodes.Node:
+ derived_from: tosca.nodes.Root
+ capability:
+ node:
+ type: tosca.capabilities.xos.Node
+
tosca.relationships.MemberOfSlice:
derived_from: tosca.relationships.Root
valid_target_types: [ tosca.capabilities.xos.Slice ]
@@ -451,6 +460,10 @@
derived_from: tosca.relationships.Root
valid_target_types: [ tosca.capabilities.xos.Site ]
+ tosca.relationships.MemberOfDeployment:
+ derived_from: tosca.relationships.Root
+ valid_target_types: [ tosca.capabilities.xos.Deployment ]
+
tosca.relationships.TenantOfService:
derived_from: tosca.relationships.Root
valid_target_types: [ tosca.capabilities.xos.Service ]
@@ -540,3 +553,7 @@
derived_from: tosca.capabilities.Root
description: An XOS Subscriber
+ tosca.capabilities.xos.Node:
+ derived_from: tosca.capabilities.Root
+ description: An XOS Node
+
diff --git a/xos/tosca/resources/VOLTTenant.py b/xos/tosca/resources/VOLTTenant.py
index 611bf23..f00b515 100644
--- a/xos/tosca/resources/VOLTTenant.py
+++ b/xos/tosca/resources/VOLTTenant.py
@@ -14,7 +14,7 @@
class XOSVOLTTenant(XOSResource):
provides = "tosca.nodes.VOLTTenant"
xos_model = VOLTTenant
- copyin_props = ["service_specific_id"]
+ copyin_props = ["service_specific_id", "vlan_id"]
name_field = None
def get_xos_args(self, throw_exception=True):
diff --git a/xos/tosca/resources/node.py b/xos/tosca/resources/node.py
new file mode 100644
index 0000000..ed39737
--- /dev/null
+++ b/xos/tosca/resources/node.py
@@ -0,0 +1,58 @@
+import os
+import pdb
+import sys
+import tempfile
+sys.path.append("/opt/tosca")
+from translator.toscalib.tosca_template import ToscaTemplate
+
+from core.models import Node, Site, Deployment, SiteDeployment
+
+from xosresource import XOSResource
+
+class XOSNode(XOSResource):
+ provides = "tosca.nodes.Node"
+ xos_model = Node
+
+ def get_xos_args(self):
+ args = {"name": self.nodetemplate.name}
+
+ site = None
+ siteName = self.get_requirement("tosca.relationships.MemberOfSite", throw_exception=False)
+ if siteName:
+ site = self.get_xos_object(Site, name=siteName)
+ args["site"] = site
+
+ deploymentName = self.get_requirement("tosca.relationships.MemberOfDeployment", throw_exception=False)
+ if deploymentName:
+ deployment = self.get_xos_object(Deployment, name=deploymentName)
+
+ if site:
+ siteDeployment = self.get_xos_object(SiteDeployment, site=site, deployment=deployment, throw_exception=True)
+ args["site_deployment"] = siteDeployment
+
+ return args
+
+ def create(self):
+ nodetemplate = self.nodetemplate
+ sliceName = nodetemplate.name
+
+ xos_args = self.get_xos_args()
+
+ if not xos_args.get("site", None):
+ raise Exception("Site is a required field of Node")
+ if not xos_args.get("site_deployment", None):
+ raise Exception("Deployment is a required field of Node")
+
+ node = Node(**xos_args)
+ node.caller = self.user
+ node.save()
+
+ self.postprocess(node)
+
+ self.info("Created Node '%s' on Site '%s' Deployment '%s'" % (str(node), str(node.site), str(node.site_deployment.deployment)))
+
+ def delete(self, obj):
+ super(XOSNode, self).delete(obj)
+
+
+
diff --git a/xos/tosca/resources/xossite.py b/xos/tosca/resources/xossite.py
index a65129a..997c9e9 100644
--- a/xos/tosca/resources/xossite.py
+++ b/xos/tosca/resources/xossite.py
@@ -46,7 +46,7 @@
controller_name = None
for sd_req in v["requirements"]:
for (sd_req_k, sd_req_v) in sd_req.items():
- if sd_req_v["relationship"] == "tosca.relationship.UsesController":
+ if sd_req_v["relationship"] == "tosca.relationships.UsesController":
controller_name = sd_req_v["node"]
if not controller_name:
raise Exception("Controller must be specified in SiteDeployment relationship")
diff --git a/xos/tosca/samples/cord.yaml b/xos/tosca/samples/cord.yaml
index eaa536a..477be2f 100644
--- a/xos/tosca/samples/cord.yaml
+++ b/xos/tosca/samples/cord.yaml
@@ -125,6 +125,7 @@
type: tosca.nodes.VOLTTenant
properties:
service_specific_id: 1234
+ vlan_id: 4321
requirements:
- provider_service:
node: service_volt
diff --git a/xos/tosca/samples/new_site_deploy_slice.yaml b/xos/tosca/samples/new_site_deploy_slice.yaml
index fa047a3..6ccadc1 100644
--- a/xos/tosca/samples/new_site_deploy_slice.yaml
+++ b/xos/tosca/samples/new_site_deploy_slice.yaml
@@ -40,7 +40,7 @@
requirements:
- controller:
node: newcontroller
- relationship: tosca.relationship.UsesController
+ relationship: tosca.relationships.UsesController
newsite_tosca:
type: tosca.nodes.Slice
diff --git a/xos/tosca/tests/alltests.py b/xos/tosca/tests/alltests.py
index 59ad49d..04c4ade 100644
--- a/xos/tosca/tests/alltests.py
+++ b/xos/tosca/tests/alltests.py
@@ -4,8 +4,14 @@
from servicetest import ServiceTest
from usertest import UserTest
from computetest import ComputeTest
+from sitetest import SiteTest
+from deploymenttest import DeploymentTest
+from nodetest import NodeTest
if __name__ == "__main__":
+ SiteTest()
+ DeploymentTest()
+ NodeTest()
NetworkTest()
PortTest()
CoarseTenancyTest()
diff --git a/xos/tosca/tests/basetest.py b/xos/tosca/tests/basetest.py
index f88a63b..db3ffb7 100644
--- a/xos/tosca/tests/basetest.py
+++ b/xos/tosca/tests/basetest.py
@@ -96,10 +96,13 @@
assert(False)
return obj
- def try_to_delete(self, cls, **kwargs):
- objs = cls.objects.filter(**kwargs)
- for obj in objs:
- obj.delete(purge=True)
+ def try_to_delete(self, cls, purge=True, **kwargs):
+ for obj in cls.objects.filter(**kwargs):
+ obj.delete(purge=purge)
+
+ if purge:
+ for obj in cls.deleted_objects.filter(**kwargs):
+ obj.delete(purge=True)
def execute(self, yml):
u = User.objects.get(email=self.username)
diff --git a/xos/tosca/tests/deploymenttest.py b/xos/tosca/tests/deploymenttest.py
new file mode 100644
index 0000000..188ead2
--- /dev/null
+++ b/xos/tosca/tests/deploymenttest.py
@@ -0,0 +1,28 @@
+from basetest import BaseToscaTest
+
+from core.models import Deployment
+
+class DeploymentTest(BaseToscaTest):
+ tests = ["create_deployment_minimal",
+ "destroy_deployment",
+ ]
+
+ def cleanup(self):
+ self.try_to_delete(Deployment, name="testdep")
+
+ def create_deployment_minimal(self):
+ self.assert_noobj(Deployment, "testdep")
+ self.execute(self.make_nodetemplate("testdep", "tosca.nodes.Deployment"))
+ instance = self.assert_obj(Deployment, "testdep")
+
+ def destroy_deployment(self):
+ self.assert_noobj(Deployment, "testdep")
+ self.execute(self.make_nodetemplate("testdep", "tosca.nodes.Deployment"))
+ instance = self.assert_obj(Deployment, "testdep")
+ self.destroy(self.make_nodetemplate("testdep", "tosca.nodes.Deployment"))
+ self.assert_noobj(Deployment, "testdep")
+
+if __name__ == "__main__":
+ DeploymentTest()
+
+
diff --git a/xos/tosca/tests/nodetest.py b/xos/tosca/tests/nodetest.py
new file mode 100644
index 0000000..dad2ab0
--- /dev/null
+++ b/xos/tosca/tests/nodetest.py
@@ -0,0 +1,62 @@
+from basetest import BaseToscaTest
+
+from core.models import Node, Site, Deployment, SiteDeployment
+
+class NodeTest(BaseToscaTest):
+ tests = ["create_node_minimal",
+ "destroy_node",
+ ]
+
+ def cleanup(self):
+ self.try_to_delete(Node, name="testnode")
+ self.try_to_delete(Site, name="testsite")
+ self.try_to_delete(Deployment, name="testdep")
+
+ def get_base_templates(self):
+ return \
+"""
+ testdep:
+ type: tosca.nodes.Deployment
+ testcon:
+ type: tosca.nodes.Controller
+ requirements:
+ - deployment:
+ node: testdep
+ relationship: tosca.relationships.ControllerDeployment
+ testsite:
+ type: tosca.nodes.Site
+ requirements:
+ - deployment:
+ node: testdep
+ relationship: tosca.relationships.SiteDeployment
+ requirements:
+ - controller:
+ node: testcon
+ relationship: tosca.relationships.UsesController
+"""
+
+ def create_node_minimal(self):
+ self.assert_noobj(Node, "testnode")
+ self.execute(self.get_base_templates() +
+ self.make_nodetemplate("testnode", "tosca.nodes.Node",
+ reqs=[("testsite", "tosca.relationships.MemberOfSite"),
+ ("testdep", "tosca.relationships.MemberOfDeployment")]))
+ self.assert_obj(Node, "testnode")
+
+ def destroy_node(self):
+ self.assert_noobj(Node, "testnode")
+ self.execute(self.get_base_templates() +
+ self.make_nodetemplate("testnode", "tosca.nodes.Node",
+ reqs=[("testsite", "tosca.relationships.MemberOfSite"),
+ ("testdep", "tosca.relationships.MemberOfDeployment")]))
+ self.assert_obj(Node, "testnode")
+ self.destroy(self.get_base_templates() +
+ self.make_nodetemplate("testnode", "tosca.nodes.Node",
+ reqs=[("testsite", "tosca.relationships.MemberOfSite"),
+ ("testdep", "tosca.relationships.MemberOfDeployment")]))
+ self.assert_noobj(Node, "testnode")
+
+if __name__ == "__main__":
+ NodeTest()
+
+
diff --git a/xos/tosca/tests/observerComputeTest.py b/xos/tosca/tests/observerComputeTest.py
new file mode 100644
index 0000000..a5320ac
--- /dev/null
+++ b/xos/tosca/tests/observerComputeTest.py
@@ -0,0 +1,49 @@
+from observertest import BaseObserverToscaTest
+
+from core.models import Instance, Site
+
+class ObserverComputeTest(BaseObserverToscaTest):
+ tests = ["create_instance"]
+ # hide_observer_output = False # uncomment to display lots of stuff to screen
+
+ def cleanup(self):
+ # We don't want to leak resources, so we make sure to let the observer
+ # attempt to delete these objects.
+ self.try_to_delete(Instance, purge=False, name="test_compute1")
+ self.try_to_delete(Site, purge=False, name="testsite")
+ self.run_observer()
+ # The site objects don't seem to go away nicely, they linger about and
+ # cause an IntegrityError due to a duplicate login_base
+ self.try_to_delete(Site, purge=True, name="testsite")
+
+ def get_base_templates(self):
+ return self.make_nodetemplate("testsite", "tosca.nodes.Site") + \
+ self.make_nodetemplate("testsite_slice1", "tosca.nodes.Slice", reqs=[("testsite", "tosca.relationships.MemberOfSite")])
+
+ def create_instance(self):
+ self.assert_noobj(Instance, "test_compute1")
+ self.execute(self.get_base_templates() +
+ self.make_compute("testsite_slice1", "test_compute1", disk_size="1 GB", mem_size="513 MB"))
+ instance = self.assert_obj(Instance, "test_compute1")
+ assert(instance.flavor.name == "m1.small")
+
+ self.run_model_policy()
+
+ # first observer pass should make any necessary networks or ports
+ self.run_observer()
+
+ # reset the exponential backoff
+ instance = self.assert_obj(Instance, "test_compute1")
+ instance.backend_register="{}"
+
+ # second observer pass should instantiate the instance
+ self.run_observer()
+
+ instance = self.assert_obj(Instance, "test_compute1")
+
+ assert(instance.instance_id is not None)
+ assert(instance.instance_name is not None)
+
+if __name__ == "__main__":
+ ObserverComputeTest()
+
diff --git a/xos/tosca/tests/observertest.py b/xos/tosca/tests/observertest.py
new file mode 100644
index 0000000..32dcf24
--- /dev/null
+++ b/xos/tosca/tests/observertest.py
@@ -0,0 +1,64 @@
+from basetest import *
+
+import logging
+import StringIO
+import subprocess
+import sys
+
+from observer.event_loop import XOSObserver
+from model_policy import run_policy_once
+from xos.config import set_override
+from util.logger import Logger, observer_logger
+
+class BaseObserverToscaTest(BaseToscaTest):
+ hide_observer_output = True
+
+ def __init__(self):
+ super(BaseObserverToscaTest, self).__init__()
+
+ def ensure_observer_not_running(self):
+ ps_output = subprocess.Popen("ps -elfy", shell=True, stdout=subprocess.PIPE).stdout.read()
+ if "/opt/xos/xos-observer.py" in ps_output:
+ print >> sys.stderr, "an observer is still running"
+ print >> sys.stderr, "please stop it, for example 'supervisorctl stop observer'"
+ sys.exit(-1)
+
+ def log_to_memory(self):
+ set_override("observer_console_print", False)
+
+ if self.hide_observer_output:
+ logStream = StringIO.StringIO()
+ handler = logging.StreamHandler(stream=logStream)
+ handler.setLevel(logging.DEBUG)
+ handler.setFormatter(logging.Formatter("%(asctime)s - %(levelname)s - %(message)s"))
+
+ loggername = Logger().loggername
+ log = logging.getLogger(loggername)
+ for hdlr in log.handlers[:]:
+ log.removeHandler(hdlr)
+ log.addHandler(handler)
+ log.propagate = False
+
+ log = observer_logger.logger
+ for hdlr in log.handlers[:]:
+ log.removeHandler(hdlr)
+ log.addHandler(handler)
+ log.propagate = False
+
+ def run_model_policy(self):
+ self.ensure_observer_not_running()
+ self.log_to_memory()
+
+ #print ">>>>> run model_policies"
+ run_policy_once()
+ #print ">>>>> done model_policies"
+
+ def run_observer(self):
+ self.ensure_observer_not_running()
+ self.log_to_memory()
+
+ observer = XOSObserver()
+ #print ">>>>> run observer"
+ observer.run_once()
+ #print ">>>>> done observer"
+
diff --git a/xos/tosca/tests/sitetest.py b/xos/tosca/tests/sitetest.py
new file mode 100644
index 0000000..50a9ea0
--- /dev/null
+++ b/xos/tosca/tests/sitetest.py
@@ -0,0 +1,28 @@
+from basetest import BaseToscaTest
+
+from core.models import Site
+
+class SiteTest(BaseToscaTest):
+ tests = ["create_site_minimal",
+ "destroy_site",
+ ]
+
+ def cleanup(self):
+ self.try_to_delete(Site, name="testsite")
+
+ def create_site_minimal(self):
+ self.assert_noobj(Site, "testsite")
+ self.execute(self.make_nodetemplate("testsite", "tosca.nodes.Site"))
+ instance = self.assert_obj(Site, "testsite")
+
+ def destroy_site(self):
+ self.assert_noobj(Site, "testsite")
+ self.execute(self.make_nodetemplate("testsite", "tosca.nodes.Site"))
+ instance = self.assert_obj(Site, "testsite")
+ self.destroy(self.make_nodetemplate("testsite", "tosca.nodes.Site"))
+ self.assert_noobj(Site, "testsite")
+
+if __name__ == "__main__":
+ SiteTest()
+
+
diff --git a/xos/xos/config.py b/xos/xos/config.py
index e8b8dbc..83d69cb 100644
--- a/xos/xos/config.py
+++ b/xos/xos/config.py
@@ -25,6 +25,11 @@
def str2bool(v):
return v.lower() in ("true", "1")
+# allow the test framework to apply global overrides to the config framework
+override = {}
+def set_override(name, value):
+ override[name] = value
+
class Config:
def __init__(self, config_file=None):
@@ -251,6 +256,8 @@
self.write(filename)
def __getattr__(self, attr):
+ if attr in override:
+ return override[attr]
return getattr(self.config, attr)
if __name__ == '__main__':