});
XOSTenantSiteCollection = XOSCollection.extend( {
- listFields: ["name", "allocated"],
+ listFields: ["name", "allocated", "ready"],
modelName: "tenantSite",
collectionName: "tenantSites",
var id = 0;
for (siteName in slice.attributes.site_allocation) {
allocated = slice.attributes.site_allocation[siteName];
- tenantSites.push(new XOSTenantSite( { name: siteName, allocated: allocated, id: id} ));
+ ready = slice.attributes.site_ready[siteName] || 0;
+ tenantSites.push(new XOSTenantSite( { name: siteName, allocated: allocated, ready: ready, id: id} ));
id = id + 1;
}
for (index in xos.tenantview.models[0].attributes.blessed_site_names) {
siteName = xos.tenantview.models[0].attributes.blessed_site_names[index];
if (! (siteName in slice.attributes.site_allocation)) {
- tenantSites.push(new XOSTenantSite( { name: siteName, allocated: 0, id: id} ));
+ tenantSites.push(new XOSTenantSite( { name: siteName, allocated: 0, ready: 0, id: id} ));
id = id + 1;
}
}
this.set(tenantSites);
+
+ var that=this;
+ this.listenTo(slice, 'change', function() { that.getReadyFromSlice(slice); })
+ },
+
+ getReadyFromSlice: function(slice) {
+ for (siteName in slice.attributes.site_ready) {
+ ready = slice.attributes.site_ready[siteName];
+ for (index in this.models) {
+ tenantSite = this.models[index];
+ if (tenantSite.attributes.name == siteName) {
+ tenantSite.set("ready", ready);
+ }
+ }
+ }
},
putToSlice: function(slice) {
"click button.btn-tenant-delete": "deleteClicked",
"click button.btn-tenant-add-user": "addUserClicked",
"click button.btn-tenant-save": "saveClicked",
+ "click button.btn-tenant-download-ssh": "downloadClicked",
},
createClicked: function(e) {
XOSTenantApp.editUsers(this.options.linkedView.model);
},
+ downloadClicked: function(e) {
+ XOSTenantApp.downloadSSH(this.options.linkedView.model);
+ },
+
saveClicked: function(e) {
model = this.options.linkedView.model;
model.tenantSiteCollection.putToSlice(model);
tenantButtons: "#tenantButtons",
tenantAddSliceInterior: "#tenant-addslice-interior",
tenantEditUsersInterior: "#tenant-edit-users-interior",
+ tenantSSHCommandsInterior: "#tenant-ssh-commands-interior",
});
XOSTenantApp.setDirty = function(dirty) {
\r
tenantSummaryClass = XOSTenantSummaryView.extend({template: "#xos-detail-template",\r
app: XOSTenantApp,\r
- detailFields: ["serviceClass", "default_image", "default_flavor", "network_ports", "mount_data_sets"],\r
+ detailFields: ["serviceClass", "default_image", "default_flavor", "network_ports"],\r
fieldDisplayNames: {serviceClass: "Service Level", "default_flavor": "Flavor", "default_image": "Image", "mount_data_sets": "Data Sets"},\r
+ helpText: {"serviceClass": "Existing slivers will be re-instantiated if changed",\r
+ "default_image": "Existing slivers will be re-instantiated if changed",\r
+ "default_flavor": "Existing slivers will be re-instantiated if changed"},\r
\r
onShow: function() {\r
// the slice selector is in a different table, so make every label cell the maximal width\r
sliceChanged: function(id) {\r
XOSTenantApp.navToSlice(id);\r
},\r
+ filter: function(slice) {\r
+ return slice.attributes.current_user_can_see;\r
+ },\r
});\r
\r
xos.sites.fetch();\r
$("#tenant-edit-users-dialog").dialog("open");\r
};\r
\r
+XOSTenantApp.downloadSSH = function(model) {\r
+ var sshCommands = "";\r
+ for (index in model.attributes.sliceInfo.sshCommands) {\r
+ sshCommand = model.attributes.sliceInfo.sshCommands[index];\r
+ sshCommands = sshCommands + sshCommand + "\n";\r
+ }\r
+\r
+ if (sshCommands.length == 0) {\r
+ alert("this slice has no instantiated slivers yet");\r
+ return;\r
+ }\r
+\r
+ var htmlView = new HTMLView({html: '<pre style="overflow: auto; word-wrap: normal; white-space: pre; word-wrap: normal;">' + sshCommands + '</pre>'});\r
+ XOSTenantApp.tenantSSHCommandsInterior.show(htmlView);\r
+\r
+ $("#tenant-ssh-commands-dialog").dialog({\r
+ autoOpen: false,
+ modal: true,
+ width: 640,
+ buttons : {
+ "Download": function() {
+ var dlLink = document.createElement('a');
+ dlLink.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(sshCommands));
+ dlLink.setAttribute('download', 'sshcommands.txt');
+ dlLink.click();
+
+ //window.open('data:text/text,' + encodeURIComponent(sshCommands));
+ },
+ "Close" : function() {
+ $(this).dialog("close");
+ },
+ }
+ });
+ $("#tenant-ssh-commands-dialog").dialog("open");\r
+};\r
+\r
XOSTenantApp.deleteSlice = function(model) {\r
var app=this;\r
app.deleteDialog(model, function() { console.log("afterDelete"); app.viewSlice(undefined); });\r